diff options
author | Carl Dong <contact@carldong.me> | 2021-09-20 16:44:21 -0400 |
---|---|---|
committer | Carl Dong <contact@carldong.me> | 2021-12-06 15:56:55 -0500 |
commit | 9162a4f93ef5aeb57fe11a6e09f5881cf431f5e6 (patch) | |
tree | 1ef3829ddaadb842e7c20f921922ee336efb5141 /src | |
parent | c7a5c46e6fd6d6ff46ca7a65fc3f0fff3cbdb24e (diff) |
node/chainstate: Decouple from concept of NodeContext
...instead pass in only the necessary information
Also allow mempool to be a nullptr
Diffstat (limited to 'src')
-rw-r--r-- | src/init.cpp | 2 | ||||
-rw-r--r-- | src/node/chainstate.cpp | 7 | ||||
-rw-r--r-- | src/node/chainstate.h | 4 |
3 files changed, 6 insertions, 7 deletions
diff --git a/src/init.cpp b/src/init.cpp index f44373728d..eb23ae501c 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1421,7 +1421,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info) const int64_t load_block_index_start_time = GetTimeMillis(); auto rv = LoadChainstate(fReset, chainman, - node, + node.mempool.get(), fPruneMode, chainparams, fReindexChainState, diff --git a/src/node/chainstate.cpp b/src/node/chainstate.cpp index 3d02c52edb..4b0b71e00f 100644 --- a/src/node/chainstate.cpp +++ b/src/node/chainstate.cpp @@ -8,14 +8,13 @@ #include <rpc/blockchain.h> // for RPCNotifyBlockChange #include <util/time.h> // for GetTime #include <node/blockstorage.h> // for CleanupBlockRevFiles, fHavePruned, fReindex -#include <node/context.h> // for NodeContext #include <node/ui_interface.h> // for InitError, uiInterface, and CClientUIInterface member access #include <shutdown.h> // for ShutdownRequested #include <validation.h> // for a lot of things std::optional<ChainstateLoadingError> LoadChainstate(bool fReset, ChainstateManager& chainman, - NodeContext& node, + CTxMemPool* mempool, bool fPruneMode, const CChainParams& chainparams, bool fReindexChainState, @@ -32,11 +31,11 @@ std::optional<ChainstateLoadingError> LoadChainstate(bool fReset, do { try { LOCK(cs_main); - chainman.InitializeChainstate(Assert(node.mempool.get())); + chainman.InitializeChainstate(Assert(mempool)); chainman.m_total_coinstip_cache = nCoinCacheUsage; chainman.m_total_coinsdb_cache = nCoinDBCache; - UnloadBlockIndex(node.mempool.get(), chainman); + UnloadBlockIndex(mempool, chainman); auto& pblocktree{chainman.m_blockman.m_block_tree_db}; // new CBlockTreeDB tries to delete the existing file, which diff --git a/src/node/chainstate.h b/src/node/chainstate.h index 87aad23e27..39621a31c5 100644 --- a/src/node/chainstate.h +++ b/src/node/chainstate.h @@ -10,7 +10,7 @@ class CChainParams; class ChainstateManager; -struct NodeContext; +class CTxMemPool; enum class ChainstateLoadingError { ERROR_LOADING_BLOCK_DB, @@ -55,7 +55,7 @@ enum class ChainstateLoadingError { */ std::optional<ChainstateLoadingError> LoadChainstate(bool fReset, ChainstateManager& chainman, - NodeContext& node, + CTxMemPool* mempool, bool fPruneMode, const CChainParams& chainparams, bool fReindexChainState, |