Skip to content

Commit fa4ee53

Browse files
author
MacroFake
committed
Do not pass time getter to Chainstate helpers
1 parent 002411d commit fa4ee53

File tree

5 files changed

+6
-11
lines changed

5 files changed

+6
-11
lines changed

src/bitcoin-chainstate.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,7 @@ int main(int argc, char* argv[])
9393
false,
9494
chainparams.GetConsensus(),
9595
DEFAULT_CHECKBLOCKS,
96-
DEFAULT_CHECKLEVEL,
97-
/*get_unix_time_seconds=*/static_cast<int64_t (*)()>(GetTime));
96+
DEFAULT_CHECKLEVEL);
9897
if (maybe_verify_error.has_value()) {
9998
std::cerr << "Failed to verify loaded Chain state from your datadir." << std::endl;
10099
goto epilogue;

src/init.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1504,8 +1504,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
15041504
fReindexChainState,
15051505
chainparams.GetConsensus(),
15061506
check_blocks,
1507-
args.GetIntArg("-checklevel", DEFAULT_CHECKLEVEL),
1508-
/*get_unix_time_seconds=*/static_cast<int64_t(*)()>(GetTime));
1507+
args.GetIntArg("-checklevel", DEFAULT_CHECKLEVEL));
15091508
} catch (const std::exception& e) {
15101509
LogPrintf("%s\n", e.what());
15111510
maybe_verify_error = ChainstateLoadVerifyError::ERROR_GENERIC_FAILURE;

src/node/chainstate.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,7 @@ std::optional<ChainstateLoadVerifyError> VerifyLoadedChainstate(ChainstateManage
128128
bool fReindexChainState,
129129
const Consensus::Params& consensus_params,
130130
int check_blocks,
131-
int check_level,
132-
std::function<int64_t()> get_unix_time_seconds)
131+
int check_level)
133132
{
134133
auto is_coinsview_empty = [&](CChainState* chainstate) EXCLUSIVE_LOCKS_REQUIRED(::cs_main) {
135134
return fReset || fReindexChainState || chainstate->CoinsTip().GetBestBlock().IsNull();
@@ -140,7 +139,7 @@ std::optional<ChainstateLoadVerifyError> VerifyLoadedChainstate(ChainstateManage
140139
for (CChainState* chainstate : chainman.GetAll()) {
141140
if (!is_coinsview_empty(chainstate)) {
142141
const CBlockIndex* tip = chainstate->m_chain.Tip();
143-
if (tip && tip->nTime > get_unix_time_seconds() + MAX_FUTURE_BLOCK_TIME) {
142+
if (tip && tip->nTime > GetTime() + MAX_FUTURE_BLOCK_TIME) {
144143
return ChainstateLoadVerifyError::ERROR_BLOCK_FROM_FUTURE;
145144
}
146145

src/node/chainstate.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,7 @@ std::optional<ChainstateLoadVerifyError> VerifyLoadedChainstate(ChainstateManage
8080
bool fReindexChainState,
8181
const Consensus::Params& consensus_params,
8282
int check_blocks,
83-
int check_level,
84-
std::function<int64_t()> get_unix_time_seconds);
83+
int check_level);
8584
} // namespace node
8685

8786
#endif // BITCOIN_NODE_CHAINSTATE_H

src/test/util/setup_common.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,7 @@ TestingSetup::TestingSetup(const std::string& chainName, const std::vector<const
216216
m_args.GetBoolArg("-reindex-chainstate", false),
217217
chainparams.GetConsensus(),
218218
m_args.GetIntArg("-checkblocks", DEFAULT_CHECKBLOCKS),
219-
m_args.GetIntArg("-checklevel", DEFAULT_CHECKLEVEL),
220-
/*get_unix_time_seconds=*/static_cast<int64_t(*)()>(GetTime));
219+
m_args.GetIntArg("-checklevel", DEFAULT_CHECKLEVEL));
221220
assert(!maybe_verify_error.has_value());
222221

223222
BlockValidationState state;

0 commit comments

Comments
 (0)