Skip to content

Commit

Permalink
Move -checkblocks LogPrintf to AppInitMain
Browse files Browse the repository at this point in the history
Summary:
Partial backport of [[bitcoin/bitcoin#23280 | core#23280]]:
bitcoin/bitcoin@8d466a8

Depends on D12572.

Test Plan:
  ninja all check-all

Reviewers: #bitcoin_abc, PiRK

Reviewed By: #bitcoin_abc, PiRK

Differential Revision: https://reviews.bitcoinabc.org/D12573
  • Loading branch information
dongcarl authored and Fabcien committed Nov 22, 2022
1 parent 9439a96 commit 2e6d9aa
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
12 changes: 10 additions & 2 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2524,9 +2524,17 @@ bool AppInitMain(Config &config, RPCServer &rpcServer,
std::optional<ChainstateLoadVerifyError> rv2;
try {
uiInterface.InitMessage(_("Verifying blocks…").translated);

auto check_blocks =
args.GetIntArg("-checkblocks", DEFAULT_CHECKBLOCKS);
if (fHavePruned && check_blocks > MIN_BLOCKS_TO_KEEP) {
LogPrintf("Prune: pruned datadir may not have more than %d "
"blocks; only checking available blocks\n",
MIN_BLOCKS_TO_KEEP);
}

rv2 = VerifyLoadedChainstate(
chainman, fReset, fReindexChainState, config,
args.GetIntArg("-checkblocks", DEFAULT_CHECKBLOCKS),
chainman, fReset, fReindexChainState, config, check_blocks,
args.GetIntArg("-checklevel", DEFAULT_CHECKLEVEL));
} catch (const std::exception &e) {
LogPrintf("%s\n", e.what());
Expand Down
6 changes: 0 additions & 6 deletions src/node/chainstate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,6 @@ VerifyLoadedChainstate(ChainstateManager &chainman, bool fReset,

for (CChainState *chainstate : chainman.GetAll()) {
if (!is_coinsview_empty(chainstate)) {
if (fHavePruned && check_blocks > MIN_BLOCKS_TO_KEEP) {
LogPrintf("Prune: pruned datadir may not have more than %d "
"blocks; only checking available blocks\n",
MIN_BLOCKS_TO_KEEP);
}

const CBlockIndex *tip = chainstate->m_chain.Tip();
RPCNotifyBlockChange(tip);
if (tip && tip->nTime > GetTime() + MAX_FUTURE_BLOCK_TIME) {
Expand Down

0 comments on commit 2e6d9aa

Please sign in to comment.