@@ -187,7 +187,7 @@ void Shutdown(NodeContext& node)
187187 // / Be sure that anything that writes files or flushes caches only does this if the respective
188188 // / module was initialized.
189189 util::ThreadRename (" shutoff" );
190- mempool. AddTransactionsUpdated (1 );
190+ if (node. mempool ) node. mempool -> AddTransactionsUpdated (1 );
191191
192192 StopHTTPRPC ();
193193 StopREST ();
@@ -231,8 +231,8 @@ void Shutdown(NodeContext& node)
231231 node.connman .reset ();
232232 node.banman .reset ();
233233
234- if (:: mempool. IsLoaded () && node.args ->GetArg (" -persistmempool" , DEFAULT_PERSIST_MEMPOOL)) {
235- DumpMempool (:: mempool);
234+ if (node. mempool && node. mempool -> IsLoaded () && node.args ->GetArg (" -persistmempool" , DEFAULT_PERSIST_MEMPOOL)) {
235+ DumpMempool (*node. mempool );
236236 }
237237
238238 if (fFeeEstimatesInitialized )
@@ -738,10 +738,7 @@ static void ThreadImport(ChainstateManager& chainman, std::vector<fs::path> vImp
738738 return ;
739739 }
740740 } // End scope of CImportingNow
741- if (args.GetArg (" -persistmempool" , DEFAULT_PERSIST_MEMPOOL)) {
742- LoadMempool (::mempool);
743- }
744- ::mempool.SetIsLoaded (!ShutdownRequested ());
741+ chainman.ActiveChainstate ().LoadMempool (args);
745742}
746743
747744/* * Sanity checks
@@ -1054,11 +1051,6 @@ bool AppInitParameterInteraction(const ArgsManager& args)
10541051 }
10551052 }
10561053
1057- // Checkmempool and checkblockindex default to true in regtest mode
1058- int ratio = std::min<int >(std::max<int >(args.GetArg (" -checkmempool" , chainparams.DefaultConsistencyChecks () ? 1 : 0 ), 0 ), 1000000 );
1059- if (ratio != 0 ) {
1060- mempool.setSanityCheck (1.0 / ratio);
1061- }
10621054 fCheckBlockIndex = args.GetBoolArg (" -checkblockindex" , chainparams.DefaultConsistencyChecks ());
10631055 fCheckpointsEnabled = args.GetBoolArg (" -checkpoints" , DEFAULT_CHECKPOINTS_ENABLED);
10641056
@@ -1368,10 +1360,18 @@ bool AppInitMain(const util::Ref& context, NodeContext& node, interfaces::BlockA
13681360 node.banman = MakeUnique<BanMan>(GetDataDir () / " banlist.dat" , &uiInterface, args.GetArg (" -bantime" , DEFAULT_MISBEHAVING_BANTIME));
13691361 assert (!node.connman );
13701362 node.connman = MakeUnique<CConnman>(GetRand (std::numeric_limits<uint64_t >::max ()), GetRand (std::numeric_limits<uint64_t >::max ()), args.GetBoolArg (" -networkactive" , true ));
1363+
13711364 // Make mempool generally available in the node context. For example the connection manager, wallet, or RPC threads,
13721365 // which are all started after this, may use it from the node context.
13731366 assert (!node.mempool );
13741367 node.mempool = &::mempool;
1368+ if (node.mempool ) {
1369+ int ratio = std::min<int >(std::max<int >(args.GetArg (" -checkmempool" , chainparams.DefaultConsistencyChecks () ? 1 : 0 ), 0 ), 1000000 );
1370+ if (ratio != 0 ) {
1371+ node.mempool ->setSanityCheck (1.0 / ratio);
1372+ }
1373+ }
1374+
13751375 assert (!node.chainman );
13761376 node.chainman = &g_chainman;
13771377 ChainstateManager& chainman = *Assert (node.chainman );
0 commit comments