aboutsummaryrefslogtreecommitdiff
path: root/src/init.cpp
diff options
context:
space:
mode:
authorMatt Corallo <git@bluematt.me>2017-07-23 18:08:50 -0400
committerMatt Corallo <git@bluematt.me>2017-08-01 16:35:02 -0400
commitfce3f4f4920714187616e76fdecbec306e8d7a8f (patch)
tree6008c3df1bd65bf60577106f8bfbbde1fe6f56ac /src/init.cpp
parentefac91e65452dd89a9b891e79bdd191208d2b44d (diff)
downloadbitcoin-fce3f4f4920714187616e76fdecbec306e8d7a8f.tar.xz
Fix resume-of-reindex-after-restart
This more clearly uses fReindex vs fReset to make sure we're not clearing our coinsdb needlessly when restarting after a reindex. It also makes it so that restarting after shutting down mid-reindex isn't treates specially at all during txdb loading code, as it shouldn't be.
Diffstat (limited to 'src/init.cpp')
-rw-r--r--src/init.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/init.cpp b/src/init.cpp
index 0ee828ce92..5cc45c52fa 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -1400,9 +1400,9 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
delete pcoinscatcher;
delete pblocktree;
- pblocktree = new CBlockTreeDB(nBlockTreeDBCache, false, fReindex);
+ pblocktree = new CBlockTreeDB(nBlockTreeDBCache, false, fReset);
- if (fReindex) {
+ if (fReset) {
pblocktree->WriteReindexing(true);
//If we're reindexing in prune mode, wipe away unusable block files and all undo data files
if (fPruneMode)
@@ -1414,6 +1414,8 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
// LoadBlockIndex will load fTxIndex from the db, or set it if
// we're reindexing. It will also load fHavePruned if we've
// ever removed a block file from disk.
+ // Note that it also sets fReindex based on the disk flag!
+ // From here on out fReindex and fReset mean something different!
if (!LoadBlockIndex(chainparams)) {
strLoadError = _("Error loading block database");
break;
@@ -1448,7 +1450,7 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
// At this point we're either in reindex or we've loaded a useful
// block tree into mapBlockIndex!
- pcoinsdbview = new CCoinsViewDB(nCoinDBCache, false, fReindex || fReindexChainState);
+ pcoinsdbview = new CCoinsViewDB(nCoinDBCache, false, fReset || fReindexChainState);
pcoinscatcher = new CCoinsViewErrorCatcher(pcoinsdbview);
// If necessary, upgrade from older database format.
@@ -1467,7 +1469,7 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
// The on-disk coinsdb is now in a good state, create the cache
pcoinsTip = new CCoinsViewCache(pcoinscatcher);
- if (!fReindex && !fReindexChainState) {
+ if (!fReset && !fReindexChainState) {
// LoadChainTip sets chainActive based on pcoinsTip's best block
if (!LoadChainTip(chainparams)) {
strLoadError = _("Error initializing block database");
@@ -1476,7 +1478,7 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
assert(chainActive.Tip() != NULL);
}
- if (!fReindex) {
+ if (!fReset) {
// Note that RewindBlockIndex MUST run even if we're about to -reindex-chainstate.
// It both disconnects blocks based on chainActive, and drops block data in
// mapBlockIndex based on lack of available witness data.
@@ -1487,7 +1489,7 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
}
}
- if (!fReindex && !fReindexChainState) {
+ if (!fReset && !fReindexChainState) {
uiInterface.InitMessage(_("Verifying blocks..."));
if (fHavePruned && GetArg("-checkblocks", DEFAULT_CHECKBLOCKS) > MIN_BLOCKS_TO_KEEP) {
LogPrintf("Prune: pruned datadir may not have more than %d blocks; only checking available blocks",