Changeset View
Changeset View
Standalone View
Standalone View
src/node/chainstate.cpp
Show First 20 Lines • Show All 247 Lines • ▼ Show 20 Lines | if (snapshot_completion == SnapshotCompletionResult::SKIPPED) { | ||||
"loading a different snapshot.")}; | "loading a different snapshot.")}; | ||||
} | } | ||||
return {ChainstateLoadStatus::SUCCESS, {}}; | return {ChainstateLoadStatus::SUCCESS, {}}; | ||||
} | } | ||||
ChainstateLoadResult | ChainstateLoadResult | ||||
VerifyLoadedChainstate(ChainstateManager &chainman, | VerifyLoadedChainstate(ChainstateManager &chainman, | ||||
const ChainstateLoadOptions &options, | const ChainstateLoadOptions &options) { | ||||
const Config &config) { | |||||
auto is_coinsview_empty = | auto is_coinsview_empty = | ||||
[&](Chainstate *chainstate) EXCLUSIVE_LOCKS_REQUIRED(::cs_main) { | [&](Chainstate *chainstate) EXCLUSIVE_LOCKS_REQUIRED(::cs_main) { | ||||
return options.reindex || options.reindex_chainstate || | return options.reindex || options.reindex_chainstate || | ||||
chainstate->CoinsTip().GetBestBlock().IsNull(); | chainstate->CoinsTip().GetBestBlock().IsNull(); | ||||
}; | }; | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
for (Chainstate *chainstate : chainman.GetAll()) { | for (Chainstate *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 > GetTime() + MAX_FUTURE_BLOCK_TIME) { | ||||
return {ChainstateLoadStatus::FAILURE, | return {ChainstateLoadStatus::FAILURE, | ||||
_("The block database contains a block which appears " | _("The block database contains a block which appears " | ||||
"to be from the future. " | "to be from the future. " | ||||
"This may be due to your computer's date and time " | "This may be due to your computer's date and time " | ||||
"being set incorrectly. " | "being set incorrectly. " | ||||
"Only rebuild the block database if you are sure " | "Only rebuild the block database if you are sure " | ||||
"that your computer's date and time are correct")}; | "that your computer's date and time are correct")}; | ||||
} | } | ||||
VerifyDBResult result = | VerifyDBResult result = CVerifyDB().VerifyDB( | ||||
CVerifyDB().VerifyDB(*chainstate, config, chainstate->CoinsDB(), | *chainstate, chainman.GetConfig(), chainstate->CoinsDB(), | ||||
options.check_level, options.check_blocks); | options.check_level, options.check_blocks); | ||||
switch (result) { | switch (result) { | ||||
case VerifyDBResult::SUCCESS: | case VerifyDBResult::SUCCESS: | ||||
case VerifyDBResult::SKIPPED_MISSING_BLOCKS: | case VerifyDBResult::SKIPPED_MISSING_BLOCKS: | ||||
break; | break; | ||||
case VerifyDBResult::INTERRUPTED: | case VerifyDBResult::INTERRUPTED: | ||||
return {ChainstateLoadStatus::INTERRUPTED, | return {ChainstateLoadStatus::INTERRUPTED, | ||||
_("Block verification was interrupted")}; | _("Block verification was interrupted")}; | ||||
case VerifyDBResult::CORRUPTED_BLOCK_DB: | case VerifyDBResult::CORRUPTED_BLOCK_DB: | ||||
Show All 16 Lines |