mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-10 20:03:34 -03:00
Remove mempool global from init
Can be reviewed with the git diff options --color-moved=dimmed-zebra --color-moved-ws=ignore-all-space --ignore-all-space
This commit is contained in:
parent
3ba25e3bdd
commit
eeee1104d7
3 changed files with 23 additions and 12 deletions
24
src/init.cpp
24
src/init.cpp
|
@ -187,7 +187,7 @@ void Shutdown(NodeContext& node)
|
||||||
/// Be sure that anything that writes files or flushes caches only does this if the respective
|
/// Be sure that anything that writes files or flushes caches only does this if the respective
|
||||||
/// module was initialized.
|
/// module was initialized.
|
||||||
util::ThreadRename("shutoff");
|
util::ThreadRename("shutoff");
|
||||||
mempool.AddTransactionsUpdated(1);
|
if (node.mempool) node.mempool->AddTransactionsUpdated(1);
|
||||||
|
|
||||||
StopHTTPRPC();
|
StopHTTPRPC();
|
||||||
StopREST();
|
StopREST();
|
||||||
|
@ -231,8 +231,8 @@ void Shutdown(NodeContext& node)
|
||||||
node.connman.reset();
|
node.connman.reset();
|
||||||
node.banman.reset();
|
node.banman.reset();
|
||||||
|
|
||||||
if (::mempool.IsLoaded() && node.args->GetArg("-persistmempool", DEFAULT_PERSIST_MEMPOOL)) {
|
if (node.mempool && node.mempool->IsLoaded() && node.args->GetArg("-persistmempool", DEFAULT_PERSIST_MEMPOOL)) {
|
||||||
DumpMempool(::mempool);
|
DumpMempool(*node.mempool);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fFeeEstimatesInitialized)
|
if (fFeeEstimatesInitialized)
|
||||||
|
@ -738,10 +738,7 @@ static void ThreadImport(ChainstateManager& chainman, std::vector<fs::path> vImp
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} // End scope of CImportingNow
|
} // End scope of CImportingNow
|
||||||
if (args.GetArg("-persistmempool", DEFAULT_PERSIST_MEMPOOL)) {
|
chainman.ActiveChainstate().LoadMempool(args);
|
||||||
LoadMempool(::mempool);
|
|
||||||
}
|
|
||||||
::mempool.SetIsLoaded(!ShutdownRequested());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Sanity checks
|
/** Sanity checks
|
||||||
|
@ -1054,11 +1051,6 @@ bool AppInitParameterInteraction(const ArgsManager& args)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Checkmempool and checkblockindex default to true in regtest mode
|
|
||||||
int ratio = std::min<int>(std::max<int>(args.GetArg("-checkmempool", chainparams.DefaultConsistencyChecks() ? 1 : 0), 0), 1000000);
|
|
||||||
if (ratio != 0) {
|
|
||||||
mempool.setSanityCheck(1.0 / ratio);
|
|
||||||
}
|
|
||||||
fCheckBlockIndex = args.GetBoolArg("-checkblockindex", chainparams.DefaultConsistencyChecks());
|
fCheckBlockIndex = args.GetBoolArg("-checkblockindex", chainparams.DefaultConsistencyChecks());
|
||||||
fCheckpointsEnabled = args.GetBoolArg("-checkpoints", DEFAULT_CHECKPOINTS_ENABLED);
|
fCheckpointsEnabled = args.GetBoolArg("-checkpoints", DEFAULT_CHECKPOINTS_ENABLED);
|
||||||
|
|
||||||
|
@ -1368,10 +1360,18 @@ bool AppInitMain(const util::Ref& context, NodeContext& node, interfaces::BlockA
|
||||||
node.banman = MakeUnique<BanMan>(GetDataDir() / "banlist.dat", &uiInterface, args.GetArg("-bantime", DEFAULT_MISBEHAVING_BANTIME));
|
node.banman = MakeUnique<BanMan>(GetDataDir() / "banlist.dat", &uiInterface, args.GetArg("-bantime", DEFAULT_MISBEHAVING_BANTIME));
|
||||||
assert(!node.connman);
|
assert(!node.connman);
|
||||||
node.connman = MakeUnique<CConnman>(GetRand(std::numeric_limits<uint64_t>::max()), GetRand(std::numeric_limits<uint64_t>::max()), args.GetBoolArg("-networkactive", true));
|
node.connman = MakeUnique<CConnman>(GetRand(std::numeric_limits<uint64_t>::max()), GetRand(std::numeric_limits<uint64_t>::max()), args.GetBoolArg("-networkactive", true));
|
||||||
|
|
||||||
// Make mempool generally available in the node context. For example the connection manager, wallet, or RPC threads,
|
// Make mempool generally available in the node context. For example the connection manager, wallet, or RPC threads,
|
||||||
// which are all started after this, may use it from the node context.
|
// which are all started after this, may use it from the node context.
|
||||||
assert(!node.mempool);
|
assert(!node.mempool);
|
||||||
node.mempool = &::mempool;
|
node.mempool = &::mempool;
|
||||||
|
if (node.mempool) {
|
||||||
|
int ratio = std::min<int>(std::max<int>(args.GetArg("-checkmempool", chainparams.DefaultConsistencyChecks() ? 1 : 0), 0), 1000000);
|
||||||
|
if (ratio != 0) {
|
||||||
|
node.mempool->setSanityCheck(1.0 / ratio);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
assert(!node.chainman);
|
assert(!node.chainman);
|
||||||
node.chainman = &g_chainman;
|
node.chainman = &g_chainman;
|
||||||
ChainstateManager& chainman = *Assert(node.chainman);
|
ChainstateManager& chainman = *Assert(node.chainman);
|
||||||
|
|
|
@ -4227,6 +4227,14 @@ bool static LoadBlockIndexDB(ChainstateManager& chainman, const CChainParams& ch
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CChainState::LoadMempool(const ArgsManager& args)
|
||||||
|
{
|
||||||
|
if (args.GetArg("-persistmempool", DEFAULT_PERSIST_MEMPOOL)) {
|
||||||
|
::LoadMempool(m_mempool);
|
||||||
|
}
|
||||||
|
m_mempool.SetIsLoaded(!ShutdownRequested());
|
||||||
|
}
|
||||||
|
|
||||||
bool CChainState::LoadChainTip(const CChainParams& chainparams)
|
bool CChainState::LoadChainTip(const CChainParams& chainparams)
|
||||||
{
|
{
|
||||||
AssertLockHeld(cs_main);
|
AssertLockHeld(cs_main);
|
||||||
|
|
|
@ -671,6 +671,9 @@ public:
|
||||||
*/
|
*/
|
||||||
void CheckBlockIndex(const Consensus::Params& consensusParams);
|
void CheckBlockIndex(const Consensus::Params& consensusParams);
|
||||||
|
|
||||||
|
/** Load the persisted mempool from disk */
|
||||||
|
void LoadMempool(const ArgsManager& args);
|
||||||
|
|
||||||
/** Update the chain tip based on database information, i.e. CoinsTip()'s best block. */
|
/** Update the chain tip based on database information, i.e. CoinsTip()'s best block. */
|
||||||
bool LoadChainTip(const CChainParams& chainparams) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
|
bool LoadChainTip(const CChainParams& chainparams) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue