mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-22 06:52:36 +01:00
node/chainstate: Decouple from ArgsManager
...instead pass in only the necessary information
This commit is contained in:
parent
ae9121f958
commit
c7a5c46e6f
3 changed files with 12 additions and 10 deletions
|
@ -1424,11 +1424,12 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
|
|||
node,
|
||||
fPruneMode,
|
||||
chainparams,
|
||||
args,
|
||||
fReindexChainState,
|
||||
nBlockTreeDBCache,
|
||||
nCoinDBCache,
|
||||
nCoinCacheUsage);
|
||||
nCoinCacheUsage,
|
||||
args.GetIntArg("-checkblocks", DEFAULT_CHECKBLOCKS),
|
||||
args.GetIntArg("-checklevel", DEFAULT_CHECKLEVEL));
|
||||
if (rv.has_value()) {
|
||||
switch (rv.value()) {
|
||||
case ChainstateLoadingError::ERROR_LOADING_BLOCK_DB:
|
||||
|
|
|
@ -18,11 +18,12 @@ std::optional<ChainstateLoadingError> LoadChainstate(bool fReset,
|
|||
NodeContext& node,
|
||||
bool fPruneMode,
|
||||
const CChainParams& chainparams,
|
||||
const ArgsManager& args,
|
||||
bool fReindexChainState,
|
||||
int64_t nBlockTreeDBCache,
|
||||
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) {
|
||||
return fReset || fReindexChainState || chainstate->CoinsTip().GetBestBlock().IsNull();
|
||||
|
@ -140,7 +141,7 @@ std::optional<ChainstateLoadingError> LoadChainstate(bool fReset,
|
|||
for (CChainState* chainstate : chainman.GetAll()) {
|
||||
if (!is_coinsview_empty(chainstate)) {
|
||||
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",
|
||||
MIN_BLOCKS_TO_KEEP);
|
||||
}
|
||||
|
@ -153,8 +154,8 @@ std::optional<ChainstateLoadingError> LoadChainstate(bool fReset,
|
|||
|
||||
if (!CVerifyDB().VerifyDB(
|
||||
*chainstate, chainparams, chainstate->CoinsDB(),
|
||||
args.GetIntArg("-checklevel", DEFAULT_CHECKLEVEL),
|
||||
args.GetIntArg("-checkblocks", DEFAULT_CHECKBLOCKS))) {
|
||||
check_level,
|
||||
check_blocks)) {
|
||||
return ChainstateLoadingError::ERROR_CORRUPTED_BLOCK_DB;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
#include <cstdint> // for int64_t
|
||||
#include <optional> // for std::optional
|
||||
|
||||
class ArgsManager;
|
||||
class CChainParams;
|
||||
class ChainstateManager;
|
||||
struct NodeContext;
|
||||
|
@ -59,10 +58,11 @@ std::optional<ChainstateLoadingError> LoadChainstate(bool fReset,
|
|||
NodeContext& node,
|
||||
bool fPruneMode,
|
||||
const CChainParams& chainparams,
|
||||
const ArgsManager& args,
|
||||
bool fReindexChainState,
|
||||
int64_t nBlockTreeDBCache,
|
||||
int64_t nCoinDBCache,
|
||||
int64_t nCoinCacheUsage);
|
||||
int64_t nCoinCacheUsage,
|
||||
unsigned int check_blocks,
|
||||
unsigned int check_level);
|
||||
|
||||
#endif // BITCOIN_NODE_CHAINSTATE_H
|
||||
|
|
Loading…
Add table
Reference in a new issue