node/chainstate: Decouple from ArgsManager

...instead pass in only the necessary information
pull/826/head
Carl Dong 3 years ago
parent ae9121f958
commit c7a5c46e6f

@ -1424,11 +1424,12 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
node, node,
fPruneMode, fPruneMode,
chainparams, chainparams,
args,
fReindexChainState, fReindexChainState,
nBlockTreeDBCache, nBlockTreeDBCache,
nCoinDBCache, nCoinDBCache,
nCoinCacheUsage); nCoinCacheUsage,
args.GetIntArg("-checkblocks", DEFAULT_CHECKBLOCKS),
args.GetIntArg("-checklevel", DEFAULT_CHECKLEVEL));
if (rv.has_value()) { if (rv.has_value()) {
switch (rv.value()) { switch (rv.value()) {
case ChainstateLoadingError::ERROR_LOADING_BLOCK_DB: case ChainstateLoadingError::ERROR_LOADING_BLOCK_DB:

@ -18,11 +18,12 @@ std::optional<ChainstateLoadingError> LoadChainstate(bool fReset,
NodeContext& node, NodeContext& node,
bool fPruneMode, bool fPruneMode,
const CChainParams& chainparams, const CChainParams& chainparams,
const ArgsManager& args,
bool fReindexChainState, bool fReindexChainState,
int64_t nBlockTreeDBCache, int64_t nBlockTreeDBCache,
int64_t nCoinDBCache, int64_t nCoinDBCache,
int64_t nCoinCacheUsage) int64_t nCoinCacheUsage,
unsigned int check_blocks,
unsigned int check_level)
{ {
auto is_coinsview_empty = [&](CChainState* chainstate) EXCLUSIVE_LOCKS_REQUIRED(::cs_main) { auto is_coinsview_empty = [&](CChainState* chainstate) EXCLUSIVE_LOCKS_REQUIRED(::cs_main) {
return fReset || fReindexChainState || chainstate->CoinsTip().GetBestBlock().IsNull(); return fReset || fReindexChainState || chainstate->CoinsTip().GetBestBlock().IsNull();
@ -140,7 +141,7 @@ std::optional<ChainstateLoadingError> LoadChainstate(bool fReset,
for (CChainState* chainstate : chainman.GetAll()) { for (CChainState* chainstate : chainman.GetAll()) {
if (!is_coinsview_empty(chainstate)) { if (!is_coinsview_empty(chainstate)) {
uiInterface.InitMessage(_("Verifying blocks…").translated); uiInterface.InitMessage(_("Verifying blocks…").translated);
if (fHavePruned && args.GetIntArg("-checkblocks", DEFAULT_CHECKBLOCKS) > MIN_BLOCKS_TO_KEEP) { if (fHavePruned && check_blocks > MIN_BLOCKS_TO_KEEP) {
LogPrintf("Prune: pruned datadir may not have more than %d blocks; only checking available blocks\n", LogPrintf("Prune: pruned datadir may not have more than %d blocks; only checking available blocks\n",
MIN_BLOCKS_TO_KEEP); MIN_BLOCKS_TO_KEEP);
} }
@ -153,8 +154,8 @@ std::optional<ChainstateLoadingError> LoadChainstate(bool fReset,
if (!CVerifyDB().VerifyDB( if (!CVerifyDB().VerifyDB(
*chainstate, chainparams, chainstate->CoinsDB(), *chainstate, chainparams, chainstate->CoinsDB(),
args.GetIntArg("-checklevel", DEFAULT_CHECKLEVEL), check_level,
args.GetIntArg("-checkblocks", DEFAULT_CHECKBLOCKS))) { check_blocks)) {
return ChainstateLoadingError::ERROR_CORRUPTED_BLOCK_DB; return ChainstateLoadingError::ERROR_CORRUPTED_BLOCK_DB;
} }
} }

@ -8,7 +8,6 @@
#include <cstdint> // for int64_t #include <cstdint> // for int64_t
#include <optional> // for std::optional #include <optional> // for std::optional
class ArgsManager;
class CChainParams; class CChainParams;
class ChainstateManager; class ChainstateManager;
struct NodeContext; struct NodeContext;
@ -59,10 +58,11 @@ std::optional<ChainstateLoadingError> LoadChainstate(bool fReset,
NodeContext& node, NodeContext& node,
bool fPruneMode, bool fPruneMode,
const CChainParams& chainparams, const CChainParams& chainparams,
const ArgsManager& args,
bool fReindexChainState, bool fReindexChainState,
int64_t nBlockTreeDBCache, int64_t nBlockTreeDBCache,
int64_t nCoinDBCache, int64_t nCoinDBCache,
int64_t nCoinCacheUsage); int64_t nCoinCacheUsage,
unsigned int check_blocks,
unsigned int check_level);
#endif // BITCOIN_NODE_CHAINSTATE_H #endif // BITCOIN_NODE_CHAINSTATE_H

Loading…
Cancel
Save