Skip to content

Commit 9162a4f

Browse files
committed
node/chainstate: Decouple from concept of NodeContext
...instead pass in only the necessary information Also allow mempool to be a nullptr
1 parent c7a5c46 commit 9162a4f

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

src/init.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1421,7 +1421,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
14211421
const int64_t load_block_index_start_time = GetTimeMillis();
14221422
auto rv = LoadChainstate(fReset,
14231423
chainman,
1424-
node,
1424+
node.mempool.get(),
14251425
fPruneMode,
14261426
chainparams,
14271427
fReindexChainState,

src/node/chainstate.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,13 @@
88
#include <rpc/blockchain.h> // for RPCNotifyBlockChange
99
#include <util/time.h> // for GetTime
1010
#include <node/blockstorage.h> // for CleanupBlockRevFiles, fHavePruned, fReindex
11-
#include <node/context.h> // for NodeContext
1211
#include <node/ui_interface.h> // for InitError, uiInterface, and CClientUIInterface member access
1312
#include <shutdown.h> // for ShutdownRequested
1413
#include <validation.h> // for a lot of things
1514

1615
std::optional<ChainstateLoadingError> LoadChainstate(bool fReset,
1716
ChainstateManager& chainman,
18-
NodeContext& node,
17+
CTxMemPool* mempool,
1918
bool fPruneMode,
2019
const CChainParams& chainparams,
2120
bool fReindexChainState,
@@ -32,11 +31,11 @@ std::optional<ChainstateLoadingError> LoadChainstate(bool fReset,
3231
do {
3332
try {
3433
LOCK(cs_main);
35-
chainman.InitializeChainstate(Assert(node.mempool.get()));
34+
chainman.InitializeChainstate(Assert(mempool));
3635
chainman.m_total_coinstip_cache = nCoinCacheUsage;
3736
chainman.m_total_coinsdb_cache = nCoinDBCache;
3837

39-
UnloadBlockIndex(node.mempool.get(), chainman);
38+
UnloadBlockIndex(mempool, chainman);
4039

4140
auto& pblocktree{chainman.m_blockman.m_block_tree_db};
4241
// new CBlockTreeDB tries to delete the existing file, which

src/node/chainstate.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
class CChainParams;
1212
class ChainstateManager;
13-
struct NodeContext;
13+
class CTxMemPool;
1414

1515
enum class ChainstateLoadingError {
1616
ERROR_LOADING_BLOCK_DB,
@@ -55,7 +55,7 @@ enum class ChainstateLoadingError {
5555
*/
5656
std::optional<ChainstateLoadingError> LoadChainstate(bool fReset,
5757
ChainstateManager& chainman,
58-
NodeContext& node,
58+
CTxMemPool* mempool,
5959
bool fPruneMode,
6060
const CChainParams& chainparams,
6161
bool fReindexChainState,

0 commit comments

Comments
 (0)