diff options
author | Carl Dong <contact@carldong.me> | 2021-11-10 15:57:14 -0500 |
---|---|---|
committer | Carl Dong <contact@carldong.me> | 2021-12-06 15:58:10 -0500 |
commit | ca7c0b934db68acdc410e3a82f1ed898382da2e5 (patch) | |
tree | f270e09b1d92fd1e3ac37e85e68a7f3918add8f0 /src/init.cpp | |
parent | adf4912d77496b9a243476c5944528f95641f14d (diff) |
Split off VerifyLoadedChainstate
Diffstat (limited to 'src/init.cpp')
-rw-r--r-- | src/init.cpp | 38 |
1 files changed, 25 insertions, 13 deletions
diff --git a/src/init.cpp b/src/init.cpp index 0db5464fbc..e52ea57bdb 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1427,9 +1427,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info) fReindexChainState, nBlockTreeDBCache, nCoinDBCache, - nCoinCacheUsage, - args.GetIntArg("-checkblocks", DEFAULT_CHECKBLOCKS), - args.GetIntArg("-checklevel", DEFAULT_CHECKLEVEL)); + nCoinCacheUsage); if (rv.has_value()) { switch (rv.value()) { case ChainstateLoadingError::ERROR_LOADING_BLOCK_DB: @@ -1461,20 +1459,34 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info) strLoadError = strprintf(_("Witness data for blocks after height %d requires validation. Please restart with -reindex."), chainparams.GetConsensus().SegwitHeight); break; - case ChainstateLoadingError::ERROR_BLOCK_FROM_FUTURE: - strLoadError = _("The block database contains a block which appears to be from the future. " - "This may be due to your computer's date and time being set incorrectly. " - "Only rebuild the block database if you are sure that your computer's date and time are correct"); - break; - case ChainstateLoadingError::ERROR_CORRUPTED_BLOCK_DB: - strLoadError = _("Corrupted block database detected"); - break; case ChainstateLoadingError::SHUTDOWN_PROBED: break; } } else { - fLoaded = true; - LogPrintf(" block index %15dms\n", GetTimeMillis() - load_block_index_start_time); + auto rv2 = VerifyLoadedChainstate(chainman, + fReset, + fReindexChainState, + chainparams, + args.GetIntArg("-checkblocks", DEFAULT_CHECKBLOCKS), + args.GetIntArg("-checklevel", DEFAULT_CHECKLEVEL)); + if (rv2.has_value()) { + switch (rv2.value()) { + case ChainstateLoadVerifyError::ERROR_BLOCK_FROM_FUTURE: + strLoadError = _("The block database contains a block which appears to be from the future. " + "This may be due to your computer's date and time being set incorrectly. " + "Only rebuild the block database if you are sure that your computer's date and time are correct"); + break; + case ChainstateLoadVerifyError::ERROR_CORRUPTED_BLOCK_DB: + strLoadError = _("Corrupted block database detected"); + break; + case ChainstateLoadVerifyError::ERROR_GENERIC_FAILURE: + strLoadError = _("Error opening block database"); + break; + } + } else { + fLoaded = true; + LogPrintf(" block index %15dms\n", GetTimeMillis() - load_block_index_start_time); + } } if (!fLoaded && !ShutdownRequested()) { |