Skip to content

Commit 13ab353

Browse files
committed
Check for empty coinsview instead of just-reset coinsview in init
This fixes a few cases where we should be treating a restart-after- coinsviewdb-reset identically to a just-reset-coinsviewdb. Thanks to @morcos for identifying the bug.
1 parent fce3f4f commit 13ab353

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/init.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1469,7 +1469,8 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
14691469
// The on-disk coinsdb is now in a good state, create the cache
14701470
pcoinsTip = new CCoinsViewCache(pcoinscatcher);
14711471

1472-
if (!fReset && !fReindexChainState) {
1472+
bool is_coinsview_empty = fReset || fReindexChainState || pcoinsTip->GetBestBlock().IsNull();
1473+
if (!is_coinsview_empty) {
14731474
// LoadChainTip sets chainActive based on pcoinsTip's best block
14741475
if (!LoadChainTip(chainparams)) {
14751476
strLoadError = _("Error initializing block database");
@@ -1489,7 +1490,7 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
14891490
}
14901491
}
14911492

1492-
if (!fReset && !fReindexChainState) {
1493+
if (!is_coinsview_empty) {
14931494
uiInterface.InitMessage(_("Verifying blocks..."));
14941495
if (fHavePruned && GetArg("-checkblocks", DEFAULT_CHECKBLOCKS) > MIN_BLOCKS_TO_KEEP) {
14951496
LogPrintf("Prune: pruned datadir may not have more than %d blocks; only checking available blocks",

0 commit comments

Comments
 (0)