mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-06-21 22:31:21 +02:00
node/chainstate: Decouple from concept of NodeContext
...instead pass in only the necessary information Also allow mempool to be a nullptr
This commit is contained in:
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();
|
const int64_t load_block_index_start_time = GetTimeMillis();
|
||||||
auto rv = LoadChainstate(fReset,
|
auto rv = LoadChainstate(fReset,
|
||||||
chainman,
|
chainman,
|
||||||
node,
|
node.mempool.get(),
|
||||||
fPruneMode,
|
fPruneMode,
|
||||||
chainparams,
|
chainparams,
|
||||||
fReindexChainState,
|
fReindexChainState,
|
||||||
|
@ -8,14 +8,13 @@
|
|||||||
#include <rpc/blockchain.h> // for RPCNotifyBlockChange
|
#include <rpc/blockchain.h> // for RPCNotifyBlockChange
|
||||||
#include <util/time.h> // for GetTime
|
#include <util/time.h> // for GetTime
|
||||||
#include <node/blockstorage.h> // for CleanupBlockRevFiles, fHavePruned, fReindex
|
#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 <node/ui_interface.h> // for InitError, uiInterface, and CClientUIInterface member access
|
||||||
#include <shutdown.h> // for ShutdownRequested
|
#include <shutdown.h> // for ShutdownRequested
|
||||||
#include <validation.h> // for a lot of things
|
#include <validation.h> // for a lot of things
|
||||||
|
|
||||||
std::optional<ChainstateLoadingError> LoadChainstate(bool fReset,
|
std::optional<ChainstateLoadingError> LoadChainstate(bool fReset,
|
||||||
ChainstateManager& chainman,
|
ChainstateManager& chainman,
|
||||||
NodeContext& node,
|
CTxMemPool* mempool,
|
||||||
bool fPruneMode,
|
bool fPruneMode,
|
||||||
const CChainParams& chainparams,
|
const CChainParams& chainparams,
|
||||||
bool fReindexChainState,
|
bool fReindexChainState,
|
||||||
@ -32,11 +31,11 @@ std::optional<ChainstateLoadingError> LoadChainstate(bool fReset,
|
|||||||
do {
|
do {
|
||||||
try {
|
try {
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
chainman.InitializeChainstate(Assert(node.mempool.get()));
|
chainman.InitializeChainstate(Assert(mempool));
|
||||||
chainman.m_total_coinstip_cache = nCoinCacheUsage;
|
chainman.m_total_coinstip_cache = nCoinCacheUsage;
|
||||||
chainman.m_total_coinsdb_cache = nCoinDBCache;
|
chainman.m_total_coinsdb_cache = nCoinDBCache;
|
||||||
|
|
||||||
UnloadBlockIndex(node.mempool.get(), chainman);
|
UnloadBlockIndex(mempool, chainman);
|
||||||
|
|
||||||
auto& pblocktree{chainman.m_blockman.m_block_tree_db};
|
auto& pblocktree{chainman.m_blockman.m_block_tree_db};
|
||||||
// new CBlockTreeDB tries to delete the existing file, which
|
// new CBlockTreeDB tries to delete the existing file, which
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
class CChainParams;
|
class CChainParams;
|
||||||
class ChainstateManager;
|
class ChainstateManager;
|
||||||
struct NodeContext;
|
class CTxMemPool;
|
||||||
|
|
||||||
enum class ChainstateLoadingError {
|
enum class ChainstateLoadingError {
|
||||||
ERROR_LOADING_BLOCK_DB,
|
ERROR_LOADING_BLOCK_DB,
|
||||||
@ -55,7 +55,7 @@ enum class ChainstateLoadingError {
|
|||||||
*/
|
*/
|
||||||
std::optional<ChainstateLoadingError> LoadChainstate(bool fReset,
|
std::optional<ChainstateLoadingError> LoadChainstate(bool fReset,
|
||||||
ChainstateManager& chainman,
|
ChainstateManager& chainman,
|
||||||
NodeContext& node,
|
CTxMemPool* mempool,
|
||||||
bool fPruneMode,
|
bool fPruneMode,
|
||||||
const CChainParams& chainparams,
|
const CChainParams& chainparams,
|
||||||
bool fReindexChainState,
|
bool fReindexChainState,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user