node/chainstate: Decouple from concept of NodeContext

...instead pass in only the necessary information

Also allow mempool to be a nullptr
pull/826/head
Carl Dong 3 years ago
parent c7a5c46e6f
commit 9162a4f93e

@ -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,

@ -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

@ -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,

Loading…
Cancel
Save