mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-08-08 17:12:50 +02:00
Do not pass time getter to Chainstate helpers
This commit is contained in:
@@ -93,8 +93,7 @@ int main(int argc, char* argv[])
|
|||||||
false,
|
false,
|
||||||
chainparams.GetConsensus(),
|
chainparams.GetConsensus(),
|
||||||
DEFAULT_CHECKBLOCKS,
|
DEFAULT_CHECKBLOCKS,
|
||||||
DEFAULT_CHECKLEVEL,
|
DEFAULT_CHECKLEVEL);
|
||||||
/*get_unix_time_seconds=*/static_cast<int64_t (*)()>(GetTime));
|
|
||||||
if (maybe_verify_error.has_value()) {
|
if (maybe_verify_error.has_value()) {
|
||||||
std::cerr << "Failed to verify loaded Chain state from your datadir." << std::endl;
|
std::cerr << "Failed to verify loaded Chain state from your datadir." << std::endl;
|
||||||
goto epilogue;
|
goto epilogue;
|
||||||
|
@@ -1504,8 +1504,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
|
|||||||
fReindexChainState,
|
fReindexChainState,
|
||||||
chainparams.GetConsensus(),
|
chainparams.GetConsensus(),
|
||||||
check_blocks,
|
check_blocks,
|
||||||
args.GetIntArg("-checklevel", DEFAULT_CHECKLEVEL),
|
args.GetIntArg("-checklevel", DEFAULT_CHECKLEVEL));
|
||||||
/*get_unix_time_seconds=*/static_cast<int64_t(*)()>(GetTime));
|
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
LogPrintf("%s\n", e.what());
|
LogPrintf("%s\n", e.what());
|
||||||
maybe_verify_error = ChainstateLoadVerifyError::ERROR_GENERIC_FAILURE;
|
maybe_verify_error = ChainstateLoadVerifyError::ERROR_GENERIC_FAILURE;
|
||||||
|
@@ -128,8 +128,7 @@ std::optional<ChainstateLoadVerifyError> VerifyLoadedChainstate(ChainstateManage
|
|||||||
bool fReindexChainState,
|
bool fReindexChainState,
|
||||||
const Consensus::Params& consensus_params,
|
const Consensus::Params& consensus_params,
|
||||||
int check_blocks,
|
int check_blocks,
|
||||||
int check_level,
|
int check_level)
|
||||||
std::function<int64_t()> get_unix_time_seconds)
|
|
||||||
{
|
{
|
||||||
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 +139,7 @@ std::optional<ChainstateLoadVerifyError> VerifyLoadedChainstate(ChainstateManage
|
|||||||
for (CChainState* chainstate : chainman.GetAll()) {
|
for (CChainState* chainstate : chainman.GetAll()) {
|
||||||
if (!is_coinsview_empty(chainstate)) {
|
if (!is_coinsview_empty(chainstate)) {
|
||||||
const CBlockIndex* tip = chainstate->m_chain.Tip();
|
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;
|
return ChainstateLoadVerifyError::ERROR_BLOCK_FROM_FUTURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -80,8 +80,7 @@ std::optional<ChainstateLoadVerifyError> VerifyLoadedChainstate(ChainstateManage
|
|||||||
bool fReindexChainState,
|
bool fReindexChainState,
|
||||||
const Consensus::Params& consensus_params,
|
const Consensus::Params& consensus_params,
|
||||||
int check_blocks,
|
int check_blocks,
|
||||||
int check_level,
|
int check_level);
|
||||||
std::function<int64_t()> get_unix_time_seconds);
|
|
||||||
} // namespace node
|
} // namespace node
|
||||||
|
|
||||||
#endif // BITCOIN_NODE_CHAINSTATE_H
|
#endif // BITCOIN_NODE_CHAINSTATE_H
|
||||||
|
@@ -216,8 +216,7 @@ TestingSetup::TestingSetup(const std::string& chainName, const std::vector<const
|
|||||||
m_args.GetBoolArg("-reindex-chainstate", false),
|
m_args.GetBoolArg("-reindex-chainstate", false),
|
||||||
chainparams.GetConsensus(),
|
chainparams.GetConsensus(),
|
||||||
m_args.GetIntArg("-checkblocks", DEFAULT_CHECKBLOCKS),
|
m_args.GetIntArg("-checkblocks", DEFAULT_CHECKBLOCKS),
|
||||||
m_args.GetIntArg("-checklevel", DEFAULT_CHECKLEVEL),
|
m_args.GetIntArg("-checklevel", DEFAULT_CHECKLEVEL));
|
||||||
/*get_unix_time_seconds=*/static_cast<int64_t(*)()>(GetTime));
|
|
||||||
assert(!maybe_verify_error.has_value());
|
assert(!maybe_verify_error.has_value());
|
||||||
|
|
||||||
BlockValidationState state;
|
BlockValidationState state;
|
||||||
|
Reference in New Issue
Block a user