brought back fReset

This commit is contained in:
Brannon King 2020-02-19 17:01:21 -07:00 committed by Anthony Fieroni
parent daf90c3adf
commit ae9b82a721

View file

@ -1469,6 +1469,7 @@ bool AppInitMain(InitInterfaces& interfaces)
bool fLoaded = false; bool fLoaded = false;
while (!fLoaded && !ShutdownRequested()) { while (!fLoaded && !ShutdownRequested()) {
bool fReset = fReindex; // reindex flag gets changed out from underneath us
std::string strLoadError; std::string strLoadError;
uiInterface.InitMessage(_("Loading block index...").translated); uiInterface.InitMessage(_("Loading block index...").translated);
@ -1485,7 +1486,7 @@ bool AppInitMain(InitInterfaces& interfaces)
// new CBlockTreeDB tries to delete the existing file, which // new CBlockTreeDB tries to delete the existing file, which
// fails if it's still open from the previous loop. Close it first: // fails if it's still open from the previous loop. Close it first:
pblocktree.reset(); pblocktree.reset();
pblocktree.reset(new CBlockTreeDB(nBlockTreeDBCache, false, fReindex)); pblocktree.reset(new CBlockTreeDB(nBlockTreeDBCache, false, fReset));
// use faster N way hash function // use faster N way hash function
// NOTE: it assumes memory is continuous // NOTE: it assumes memory is continuous
@ -1494,7 +1495,7 @@ bool AppInitMain(InitInterfaces& interfaces)
SHA256D64(hashes[0].begin(), hashes[0].begin(), hashes.size() / 2); SHA256D64(hashes[0].begin(), hashes[0].begin(), hashes.size() / 2);
}; };
if (fReindex) { if (fReset) {
pblocktree->WriteReindexing(true); pblocktree->WriteReindexing(true);
//If we're reindexing in prune mode, wipe away unusable block files and all undo data files //If we're reindexing in prune mode, wipe away unusable block files and all undo data files
if (fPruneMode) if (fPruneMode)
@ -1542,7 +1543,7 @@ bool AppInitMain(InitInterfaces& interfaces)
::ChainstateActive().InitCoinsDB( ::ChainstateActive().InitCoinsDB(
/* cache_size_bytes */ nCoinDBCache, /* cache_size_bytes */ nCoinDBCache,
/* in_memory */ false, /* in_memory */ false,
/* should_wipe */ fReindex || fReindexChainState); /* should_wipe */ fReset || fReindexChainState);
::ChainstateActive().CoinsErrorCatcher().AddReadErrCallback([]() { ::ChainstateActive().CoinsErrorCatcher().AddReadErrCallback([]() {
uiInterface.ThreadSafeMessageBox( uiInterface.ThreadSafeMessageBox(
@ -1560,7 +1561,7 @@ bool AppInitMain(InitInterfaces& interfaces)
::ChainstateActive().InitCoinsCache(); ::ChainstateActive().InitCoinsCache();
assert(::ChainstateActive().CanFlushToDisk()); assert(::ChainstateActive().CanFlushToDisk());
is_coinsview_empty = fReindex || fReindexChainState || is_coinsview_empty = fReset || fReindexChainState ||
::ChainstateActive().CoinsTip().GetBestBlock().IsNull(); ::ChainstateActive().CoinsTip().GetBestBlock().IsNull();
if (!is_coinsview_empty) { if (!is_coinsview_empty) {
// LoadChainTip initializes the chain based on CoinsTip()'s best block // LoadChainTip initializes the chain based on CoinsTip()'s best block
@ -1582,7 +1583,7 @@ bool AppInitMain(InitInterfaces& interfaces)
break; break;
} }
if (!fReindex) { if (!fReset) {
// Note that RewindBlockIndex MUST run even if we're about to -reindex-chainstate. // 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 // It both disconnects blocks based on ::ChainActive(), and drops block data in
// BlockIndex() based on lack of available witness data. // BlockIndex() based on lack of available witness data.
@ -1629,7 +1630,7 @@ bool AppInitMain(InitInterfaces& interfaces)
if (!fLoaded && !ShutdownRequested()) { if (!fLoaded && !ShutdownRequested()) {
// first suggest a reindex // first suggest a reindex
if (!fReindex) { if (!fReset) {
bool fRet = uiInterface.ThreadSafeQuestion( bool fRet = uiInterface.ThreadSafeQuestion(
strLoadError + ".\n\n" + _("Do you want to rebuild the block database now?").translated, strLoadError + ".\n\n" + _("Do you want to rebuild the block database now?").translated,
strLoadError + ".\nPlease restart with -reindex to recover.", strLoadError + ".\nPlease restart with -reindex to recover.",