From fa4ee53dca5ccf1b87f019f372ffc10528add943 Mon Sep 17 00:00:00 2001 From: MacroFake Date: Wed, 18 May 2022 18:31:19 +0200 Subject: Do not pass time getter to Chainstate helpers --- src/bitcoin-chainstate.cpp | 3 +-- src/init.cpp | 3 +-- src/node/chainstate.cpp | 5 ++--- src/node/chainstate.h | 3 +-- src/test/util/setup_common.cpp | 3 +-- 5 files changed, 6 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/bitcoin-chainstate.cpp b/src/bitcoin-chainstate.cpp index ab805ac1ec..2632404418 100644 --- a/src/bitcoin-chainstate.cpp +++ b/src/bitcoin-chainstate.cpp @@ -93,8 +93,7 @@ int main(int argc, char* argv[]) false, chainparams.GetConsensus(), DEFAULT_CHECKBLOCKS, - DEFAULT_CHECKLEVEL, - /*get_unix_time_seconds=*/static_cast(GetTime)); + DEFAULT_CHECKLEVEL); if (maybe_verify_error.has_value()) { std::cerr << "Failed to verify loaded Chain state from your datadir." << std::endl; goto epilogue; diff --git a/src/init.cpp b/src/init.cpp index e180a2b5cd..cf1cd704a1 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1504,8 +1504,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info) fReindexChainState, chainparams.GetConsensus(), check_blocks, - args.GetIntArg("-checklevel", DEFAULT_CHECKLEVEL), - /*get_unix_time_seconds=*/static_cast(GetTime)); + args.GetIntArg("-checklevel", DEFAULT_CHECKLEVEL)); } catch (const std::exception& e) { LogPrintf("%s\n", e.what()); maybe_verify_error = ChainstateLoadVerifyError::ERROR_GENERIC_FAILURE; diff --git a/src/node/chainstate.cpp b/src/node/chainstate.cpp index 99615dea69..309c5f8f37 100644 --- a/src/node/chainstate.cpp +++ b/src/node/chainstate.cpp @@ -128,8 +128,7 @@ std::optional VerifyLoadedChainstate(ChainstateManage bool fReindexChainState, const Consensus::Params& consensus_params, int check_blocks, - int check_level, - std::function get_unix_time_seconds) + int check_level) { auto is_coinsview_empty = [&](CChainState* chainstate) EXCLUSIVE_LOCKS_REQUIRED(::cs_main) { return fReset || fReindexChainState || chainstate->CoinsTip().GetBestBlock().IsNull(); @@ -140,7 +139,7 @@ std::optional VerifyLoadedChainstate(ChainstateManage for (CChainState* chainstate : chainman.GetAll()) { if (!is_coinsview_empty(chainstate)) { const CBlockIndex* tip = chainstate->m_chain.Tip(); - if (tip && tip->nTime > get_unix_time_seconds() + MAX_FUTURE_BLOCK_TIME) { + if (tip && tip->nTime > GetTime() + MAX_FUTURE_BLOCK_TIME) { return ChainstateLoadVerifyError::ERROR_BLOCK_FROM_FUTURE; } diff --git a/src/node/chainstate.h b/src/node/chainstate.h index 8ba04f1436..deeca5db06 100644 --- a/src/node/chainstate.h +++ b/src/node/chainstate.h @@ -80,8 +80,7 @@ std::optional VerifyLoadedChainstate(ChainstateManage bool fReindexChainState, const Consensus::Params& consensus_params, int check_blocks, - int check_level, - std::function get_unix_time_seconds); + int check_level); } // namespace node #endif // BITCOIN_NODE_CHAINSTATE_H diff --git a/src/test/util/setup_common.cpp b/src/test/util/setup_common.cpp index 6891629f8e..0d588b137c 100644 --- a/src/test/util/setup_common.cpp +++ b/src/test/util/setup_common.cpp @@ -216,8 +216,7 @@ TestingSetup::TestingSetup(const std::string& chainName, const std::vector(GetTime)); + m_args.GetIntArg("-checklevel", DEFAULT_CHECKLEVEL)); assert(!maybe_verify_error.has_value()); BlockValidationState state; -- cgit v1.2.3