Skip to content

Commit

Permalink
[Move-only] Move Masternodes thread creation from init.cpp to tiertwo…
Browse files Browse the repository at this point in the history
…/init.cpp
  • Loading branch information
furszy committed Dec 17, 2021
1 parent e24c864 commit c0105db
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
#include "key.h"
#include "mapport.h"
#include "masternodeconfig.h"
#include "masternodeman.h"
#include "miner.h"
#include "netbase.h"
#include "net_processing.h"
Expand Down Expand Up @@ -1756,7 +1755,8 @@ bool AppInitMain()
}
#endif

threadGroup.create_thread(std::bind(&ThreadCheckMasternodes));
// Start tier two threads and jobs
StartTierTwoThreadsAndScheduleJobs(threadGroup, scheduler);

if (ShutdownRequested()) {
LogPrintf("Shutdown requested. Exiting.\n");
Expand Down
7 changes: 7 additions & 0 deletions src/tiertwo/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
#include "masternodeconfig.h"
#include "validation.h"

#include <boost/thread.hpp>

// Sets the last CACHED_BLOCK_HASHES hashes into masternode manager cache
static void LoadBlockHashesCache(CMasternodeMan& man)
{
Expand Down Expand Up @@ -143,4 +145,9 @@ bool InitActiveMN()
}
// All good
return true;
}

void StartTierTwoThreadsAndScheduleJobs(boost::thread_group& threadGroup, CScheduler& scheduler)
{
threadGroup.create_thread(std::bind(&ThreadCheckMasternodes));
}
10 changes: 10 additions & 0 deletions src/tiertwo/init.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,15 @@
#ifndef PIVX_TIERTWO_INIT_H
#define PIVX_TIERTWO_INIT_H

#include <string>

static const bool DEFAULT_MASTERNODE = false;

class CScheduler;
namespace boost {
class thread_group;
}

/** Loads from disk all the tier two related objects */
bool LoadTierTwo(int chain_active_height);

Expand All @@ -21,5 +28,8 @@ void SetBudgetFinMode(const std::string& mode);
/** Initialize the active Masternode manager */
bool InitActiveMN();

/** Starts tier two threads and jobs */
void StartTierTwoThreadsAndScheduleJobs(boost::thread_group& threadGroup, CScheduler& scheduler);


#endif //PIVX_TIERTWO_INIT_H

0 comments on commit c0105db

Please sign in to comment.