Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 30 additions & 38 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1717,6 +1717,28 @@ bool AppInitMain(const util::Ref& context, NodeContext& node, interfaces::BlockA
}
}

assert(activeMasternodeInfo.blsKeyOperator == nullptr);
assert(activeMasternodeInfo.blsPubKeyOperator == nullptr);
fMasternodeMode = false;
std::string strMasterNodeBLSPrivKey = args.GetArg("-masternodeblsprivkey", "");
if (!strMasterNodeBLSPrivKey.empty()) {
CBLSSecretKey keyOperator(ParseHex(strMasterNodeBLSPrivKey));
if (!keyOperator.IsValid()) {
return InitError(_("Invalid masternodeblsprivkey. Please see documentation."));
}
fMasternodeMode = true;
{
LOCK(activeMasternodeInfoCs);
activeMasternodeInfo.blsKeyOperator = std::make_unique<CBLSSecretKey>(keyOperator);
activeMasternodeInfo.blsPubKeyOperator = std::make_unique<CBLSPublicKey>(keyOperator.GetPublicKey());
}
LogPrintf("MASTERNODE:\n blsPubKeyOperator: %s\n", activeMasternodeInfo.blsPubKeyOperator->ToString());
} else {
LOCK(activeMasternodeInfoCs);
activeMasternodeInfo.blsKeyOperator = std::make_unique<CBLSSecretKey>();
activeMasternodeInfo.blsPubKeyOperator = std::make_unique<CBLSPublicKey>();
}

assert(!node.scheduler);
node.scheduler = MakeUnique<CScheduler>();

Expand Down Expand Up @@ -1914,6 +1936,12 @@ bool AppInitMain(const util::Ref& context, NodeContext& node, interfaces::BlockA
pdsNotificationInterface = new CDSNotificationInterface(*node.connman);
RegisterValidationInterface(pdsNotificationInterface);

if (fMasternodeMode) {
// Create and register activeMasternodeManager, will init later in ThreadImport
activeMasternodeManager = new CActiveMasternodeManager(*node.connman);
RegisterValidationInterface(activeMasternodeManager);
}

uint64_t nMaxOutboundLimit = 0; //unlimited unless -maxuploadtarget is set
uint64_t nMaxOutboundTimeframe = MAX_UPLOAD_TIMEFRAME;

Expand Down Expand Up @@ -2282,43 +2310,7 @@ bool AppInitMain(const util::Ref& context, NodeContext& node, interfaces::BlockA
return false;
}

// ********************************************************* Step 10a: Prepare Masternode related stuff
fMasternodeMode = false;
std::string strMasterNodeBLSPrivKey = args.GetArg("-masternodeblsprivkey", "");
if (!strMasterNodeBLSPrivKey.empty()) {
auto binKey = ParseHex(strMasterNodeBLSPrivKey);
CBLSSecretKey keyOperator(binKey);
if (!keyOperator.IsValid()) {
return InitError(_("Invalid masternodeblsprivkey. Please see documentation."));
}
fMasternodeMode = true;
{
LOCK(activeMasternodeInfoCs);
activeMasternodeInfo.blsKeyOperator = std::make_unique<CBLSSecretKey>(keyOperator);
activeMasternodeInfo.blsPubKeyOperator = std::make_unique<CBLSPublicKey>(
activeMasternodeInfo.blsKeyOperator->GetPublicKey());
}
LogPrintf("MASTERNODE:\n");
LogPrintf(" blsPubKeyOperator: %s\n", keyOperator.GetPublicKey().ToString());
}

if(fMasternodeMode) {
// Create and register activeMasternodeManager, will init later in ThreadImport
activeMasternodeManager = new CActiveMasternodeManager(*node.connman);
RegisterValidationInterface(activeMasternodeManager);
}

{
LOCK(activeMasternodeInfoCs);
if (activeMasternodeInfo.blsKeyOperator == nullptr) {
activeMasternodeInfo.blsKeyOperator = std::make_unique<CBLSSecretKey>();
}
if (activeMasternodeInfo.blsPubKeyOperator == nullptr) {
activeMasternodeInfo.blsPubKeyOperator = std::make_unique<CBLSPublicKey>();
}
}

// ********************************************************* Step 10b: setup CoinJoin
// ********************************************************* Step 10a: Setup CoinJoin

g_wallet_init_interface.InitCoinJoinSettings();

Expand Down Expand Up @@ -2373,7 +2365,7 @@ bool AppInitMain(const util::Ref& context, NodeContext& node, interfaces::BlockA
}
}

// ********************************************************* Step 10c: schedule Dash-specific tasks
// ********************************************************* Step 10b: schedule Dash-specific tasks

node.scheduler->scheduleEvery(std::bind(&CNetFulfilledRequestManager::DoMaintenance, std::ref(netfulfilledman)), 60 * 1000);
node.scheduler->scheduleEvery(std::bind(&CMasternodeSync::DoMaintenance, std::ref(masternodeSync), std::ref(*node.connman)), 1 * 1000);
Expand Down
5 changes: 5 additions & 0 deletions src/llmq/dkgsessionmgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ CDKGSessionManager::CDKGSessionManager(CConnman& _connman, CBLSWorker& _blsWorke
db(std::make_unique<CDBWrapper>(unitTests ? "" : (GetDataDir() / "llmq/dkgdb"), 1 << 20, unitTests, fWipe)),
blsWorker(_blsWorker), connman(_connman)
{
if (!fMasternodeMode && !CLLMQUtils::IsWatchQuorumsEnabled()) {
// Regular nodes do not care about any DKG internals, bail out
return;
}

MigrateDKG();

const Consensus::Params& consensus_params = Params().GetConsensus();
Expand Down