mirror of
https://github.com/dashpay/dash.git
synced 2024-12-24 11:32:46 +01:00
node/chainstate: Decouple from GetTime
This commit is contained in:
parent
f7aef8d331
commit
fdf803d013
@ -1971,7 +1971,8 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
|
|||||||
fReindexChainState,
|
fReindexChainState,
|
||||||
chainparams,
|
chainparams,
|
||||||
check_blocks,
|
check_blocks,
|
||||||
args.GetArg("-checklevel", DEFAULT_CHECKLEVEL));
|
args.GetArg("-checklevel", DEFAULT_CHECKLEVEL),
|
||||||
|
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());
|
||||||
rv2 = ChainstateLoadVerifyError::ERROR_GENERIC_FAILURE;
|
rv2 = ChainstateLoadVerifyError::ERROR_GENERIC_FAILURE;
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
|
|
||||||
#include <chainparams.h> // for CChainParams
|
#include <chainparams.h> // for CChainParams
|
||||||
#include <deploymentstatus.h> // for DeploymentActiveAfter
|
#include <deploymentstatus.h> // for DeploymentActiveAfter
|
||||||
#include <util/time.h> // for GetTime
|
|
||||||
#include <node/blockstorage.h> // for CleanupBlockRevFiles, fHavePruned, fReindex
|
#include <node/blockstorage.h> // for CleanupBlockRevFiles, fHavePruned, fReindex
|
||||||
#include <shutdown.h> // for ShutdownRequested
|
#include <shutdown.h> // for ShutdownRequested
|
||||||
#include <validation.h> // for a lot of things
|
#include <validation.h> // for a lot of things
|
||||||
@ -233,7 +232,8 @@ std::optional<ChainstateLoadVerifyError> VerifyLoadedChainstate(ChainstateManage
|
|||||||
bool fReindexChainState,
|
bool fReindexChainState,
|
||||||
const CChainParams& chainparams,
|
const CChainParams& chainparams,
|
||||||
unsigned int check_blocks,
|
unsigned int check_blocks,
|
||||||
unsigned int check_level)
|
unsigned 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();
|
||||||
@ -245,7 +245,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 > GetTime() + MAX_FUTURE_BLOCK_TIME) {
|
if (tip && tip->nTime > get_unix_time_seconds() + 2 * 60 * 60) {
|
||||||
return ChainstateLoadVerifyError::ERROR_BLOCK_FROM_FUTURE;
|
return ChainstateLoadVerifyError::ERROR_BLOCK_FROM_FUTURE;
|
||||||
}
|
}
|
||||||
const bool v19active{DeploymentActiveAfter(tip, chainparams.GetConsensus(), Consensus::DEPLOYMENT_V19)};
|
const bool v19active{DeploymentActiveAfter(tip, chainparams.GetConsensus(), Consensus::DEPLOYMENT_V19)};
|
||||||
|
@ -120,6 +120,7 @@ std::optional<ChainstateLoadVerifyError> VerifyLoadedChainstate(ChainstateManage
|
|||||||
bool fReindexChainState,
|
bool fReindexChainState,
|
||||||
const CChainParams& chainparams,
|
const CChainParams& chainparams,
|
||||||
unsigned int check_blocks,
|
unsigned int check_blocks,
|
||||||
unsigned int check_level);
|
unsigned int check_level,
|
||||||
|
std::function<int64_t()> get_unix_time_seconds);
|
||||||
|
|
||||||
#endif // BITCOIN_NODE_CHAINSTATE_H
|
#endif // BITCOIN_NODE_CHAINSTATE_H
|
||||||
|
Loading…
Reference in New Issue
Block a user