@@ -370,14 +370,13 @@ void PrepareShutdown(NodeContext& node)
370370 }
371371 if (fMasternodeMode ) {
372372 UnregisterValidationInterface (activeMasternodeManager.get ());
373- activeMasternodeManager.reset ();
374- }
375373
376- {
377374 LOCK (activeMasternodeInfoCs);
378375 // make sure to clean up BLS keys before global destructors are called (they have allocated from the secure memory pool)
379376 activeMasternodeInfo.blsKeyOperator .reset ();
380377 activeMasternodeInfo.blsPubKeyOperator .reset ();
378+
379+ activeMasternodeManager.reset ();
381380 }
382381
383382 node.chain_clients .clear ();
@@ -1606,34 +1605,6 @@ bool AppInitMain(const CoreContext& context, NodeContext& node, interfaces::Bloc
16061605 StartScriptCheckWorkerThreads (script_threads);
16071606 }
16081607
1609- {
1610- LOCK (activeMasternodeInfoCs);
1611- assert (activeMasternodeInfo.blsKeyOperator == nullptr );
1612- assert (activeMasternodeInfo.blsPubKeyOperator == nullptr );
1613- }
1614- fMasternodeMode = false ;
1615- std::string strMasterNodeBLSPrivKey = args.GetArg (" -masternodeblsprivkey" , " " );
1616- if (!strMasterNodeBLSPrivKey.empty ()) {
1617- CBLSSecretKey keyOperator (ParseHex (strMasterNodeBLSPrivKey));
1618- if (!keyOperator.IsValid ()) {
1619- return InitError (_ (" Invalid masternodeblsprivkey. Please see documentation." ));
1620- }
1621- fMasternodeMode = true ;
1622- {
1623- LOCK (activeMasternodeInfoCs);
1624- activeMasternodeInfo.blsKeyOperator = std::make_unique<CBLSSecretKey>(keyOperator);
1625- activeMasternodeInfo.blsPubKeyOperator = std::make_unique<CBLSPublicKey>(keyOperator.GetPublicKey ());
1626- // We don't know the actual scheme at this point, print both
1627- LogPrintf (" MASTERNODE:\n blsPubKeyOperator legacy: %s\n blsPubKeyOperator basic: %s\n " ,
1628- activeMasternodeInfo.blsPubKeyOperator ->ToString (true ),
1629- activeMasternodeInfo.blsPubKeyOperator ->ToString (false ));
1630- }
1631- } else {
1632- LOCK (activeMasternodeInfoCs);
1633- activeMasternodeInfo.blsKeyOperator = std::make_unique<CBLSSecretKey>();
1634- activeMasternodeInfo.blsPubKeyOperator = std::make_unique<CBLSPublicKey>();
1635- }
1636-
16371608 assert (!node.scheduler );
16381609 node.scheduler = std::make_unique<CScheduler>();
16391610
@@ -1878,10 +1849,30 @@ bool AppInitMain(const CoreContext& context, NodeContext& node, interfaces::Bloc
18781849 );
18791850 RegisterValidationInterface (pdsNotificationInterface);
18801851
1881- if (fMasternodeMode ) {
1882- // Create and register activeMasternodeManager, will init later in ThreadImport
1883- activeMasternodeManager = std::make_unique<CActiveMasternodeManager>(*node.connman );
1884- RegisterValidationInterface (activeMasternodeManager.get ());
1852+ fMasternodeMode = false ;
1853+ std::string strMasterNodeBLSPrivKey = args.GetArg (" -masternodeblsprivkey" , " " );
1854+ if (!strMasterNodeBLSPrivKey.empty ()) {
1855+ CBLSSecretKey keyOperator (ParseHex (strMasterNodeBLSPrivKey));
1856+ if (!keyOperator.IsValid ()) {
1857+ return InitError (_ (" Invalid masternodeblsprivkey. Please see documentation." ));
1858+ }
1859+ fMasternodeMode = true ;
1860+ {
1861+ // Create and register activeMasternodeManager, will init later in ThreadImport
1862+ activeMasternodeManager = std::make_unique<CActiveMasternodeManager>(*node.connman );
1863+
1864+ LOCK (activeMasternodeInfoCs);
1865+ assert (activeMasternodeInfo.blsKeyOperator == nullptr );
1866+ assert (activeMasternodeInfo.blsPubKeyOperator == nullptr );
1867+ activeMasternodeInfo.blsKeyOperator = std::make_unique<CBLSSecretKey>(keyOperator);
1868+ activeMasternodeInfo.blsPubKeyOperator = std::make_unique<CBLSPublicKey>(keyOperator.GetPublicKey ());
1869+ // We don't know the actual scheme at this point, print both
1870+ LogPrintf (" MASTERNODE:\n blsPubKeyOperator legacy: %s\n blsPubKeyOperator basic: %s\n " ,
1871+ activeMasternodeInfo.blsPubKeyOperator ->ToString (true ),
1872+ activeMasternodeInfo.blsPubKeyOperator ->ToString (false ));
1873+
1874+ RegisterValidationInterface (activeMasternodeManager.get ());
1875+ }
18851876 }
18861877
18871878 // ********************************************************* Step 7a: Load sporks
0 commit comments