From faf012b438b451dced785e7f031e07c0c55665e1 Mon Sep 17 00:00:00 2001 From: MacroFake Date: Wed, 18 May 2022 18:49:36 +0200 Subject: [PATCH] Do not pass Consensus::Params& to Chainstate helpers --- src/bitcoin-chainstate.cpp | 2 -- src/init.cpp | 4 +--- src/node/chainstate.cpp | 6 ++---- src/node/chainstate.h | 2 -- src/test/util/setup_common.cpp | 2 -- 5 files changed, 3 insertions(+), 13 deletions(-) diff --git a/src/bitcoin-chainstate.cpp b/src/bitcoin-chainstate.cpp index 2632404418c..812585ba1eb 100644 --- a/src/bitcoin-chainstate.cpp +++ b/src/bitcoin-chainstate.cpp @@ -76,7 +76,6 @@ int main(int argc, char* argv[]) std::ref(chainman), nullptr, false, - chainparams.GetConsensus(), false, 2 << 20, 2 << 22, @@ -91,7 +90,6 @@ int main(int argc, char* argv[]) auto maybe_verify_error = node::VerifyLoadedChainstate(std::ref(chainman), false, false, - chainparams.GetConsensus(), DEFAULT_CHECKBLOCKS, DEFAULT_CHECKLEVEL); if (maybe_verify_error.has_value()) { diff --git a/src/init.cpp b/src/init.cpp index cf1cd704a16..ee177d196d0 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1438,7 +1438,6 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info) chainman, Assert(node.mempool.get()), fPruneMode, - chainparams.GetConsensus(), fReindexChainState, cache_sizes.block_tree_db, cache_sizes.coins_db, @@ -1485,7 +1484,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info) break; case ChainstateLoadingError::ERROR_BLOCKS_WITNESS_INSUFFICIENTLY_VALIDATED: strLoadError = strprintf(_("Witness data for blocks after height %d requires validation. Please restart with -reindex."), - chainparams.GetConsensus().SegwitHeight); + chainman.GetConsensus().SegwitHeight); break; case ChainstateLoadingError::SHUTDOWN_PROBED: break; @@ -1502,7 +1501,6 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info) maybe_verify_error = VerifyLoadedChainstate(chainman, fReset, fReindexChainState, - chainparams.GetConsensus(), check_blocks, args.GetIntArg("-checklevel", DEFAULT_CHECKLEVEL)); } catch (const std::exception& e) { diff --git a/src/node/chainstate.cpp b/src/node/chainstate.cpp index 309c5f8f37c..54ba5b79663 100644 --- a/src/node/chainstate.cpp +++ b/src/node/chainstate.cpp @@ -13,7 +13,6 @@ std::optional LoadChainstate(bool fReset, ChainstateManager& chainman, CTxMemPool* mempool, bool fPruneMode, - const Consensus::Params& consensus_params, bool fReindexChainState, int64_t nBlockTreeDBCache, int64_t nCoinDBCache, @@ -57,7 +56,7 @@ std::optional LoadChainstate(bool fReset, } if (!chainman.BlockIndex().empty() && - !chainman.m_blockman.LookupBlockIndex(consensus_params.hashGenesisBlock)) { + !chainman.m_blockman.LookupBlockIndex(chainman.GetConsensus().hashGenesisBlock)) { return ChainstateLoadingError::ERROR_BAD_GENESIS_BLOCK; } @@ -126,7 +125,6 @@ std::optional LoadChainstate(bool fReset, std::optional VerifyLoadedChainstate(ChainstateManager& chainman, bool fReset, bool fReindexChainState, - const Consensus::Params& consensus_params, int check_blocks, int check_level) { @@ -144,7 +142,7 @@ std::optional VerifyLoadedChainstate(ChainstateManage } if (!CVerifyDB().VerifyDB( - *chainstate, consensus_params, chainstate->CoinsDB(), + *chainstate, chainman.GetConsensus(), chainstate->CoinsDB(), check_level, check_blocks)) { return ChainstateLoadVerifyError::ERROR_CORRUPTED_BLOCK_DB; diff --git a/src/node/chainstate.h b/src/node/chainstate.h index deeca5db06b..ff7935e8e06 100644 --- a/src/node/chainstate.h +++ b/src/node/chainstate.h @@ -59,7 +59,6 @@ std::optional LoadChainstate(bool fReset, ChainstateManager& chainman, CTxMemPool* mempool, bool fPruneMode, - const Consensus::Params& consensus_params, bool fReindexChainState, int64_t nBlockTreeDBCache, int64_t nCoinDBCache, @@ -78,7 +77,6 @@ enum class ChainstateLoadVerifyError { std::optional VerifyLoadedChainstate(ChainstateManager& chainman, bool fReset, bool fReindexChainState, - const Consensus::Params& consensus_params, int check_blocks, int check_level); } // namespace node diff --git a/src/test/util/setup_common.cpp b/src/test/util/setup_common.cpp index 0d588b137c8..3cba19b701c 100644 --- a/src/test/util/setup_common.cpp +++ b/src/test/util/setup_common.cpp @@ -201,7 +201,6 @@ TestingSetup::TestingSetup(const std::string& chainName, const std::vector