|
|
|
@ -82,6 +82,7 @@ void Shutdown(void* parg)
@@ -82,6 +82,7 @@ void Shutdown(void* parg)
|
|
|
|
|
if (fFirstThread) |
|
|
|
|
{ |
|
|
|
|
fShutdown = true; |
|
|
|
|
fRequestShutdown = true; |
|
|
|
|
nTransactionsUpdated++; |
|
|
|
|
bitdb.Flush(false); |
|
|
|
|
{ |
|
|
|
@ -791,9 +792,21 @@ bool AppInit2()
@@ -791,9 +792,21 @@ bool AppInit2()
|
|
|
|
|
nTotalCache -= nCoinDBCache; |
|
|
|
|
nCoinCacheSize = nTotalCache / 300; // coins in memory require around 300 bytes
|
|
|
|
|
|
|
|
|
|
bool fLoaded = false; |
|
|
|
|
while (!fLoaded) { |
|
|
|
|
bool fReset = fReindex; |
|
|
|
|
std::string strLoadError; |
|
|
|
|
|
|
|
|
|
uiInterface.InitMessage(_("Loading block index...")); |
|
|
|
|
|
|
|
|
|
nStart = GetTimeMillis(); |
|
|
|
|
do { |
|
|
|
|
try { |
|
|
|
|
UnloadBlockIndex(); |
|
|
|
|
delete pcoinsTip; |
|
|
|
|
delete pcoinsdbview; |
|
|
|
|
delete pblocktree; |
|
|
|
|
|
|
|
|
|
pblocktree = new CBlockTreeDB(nBlockTreeDBCache, false, fReindex); |
|
|
|
|
pcoinsdbview = new CCoinsViewDB(nCoinDBCache, false, fReindex); |
|
|
|
|
pcoinsTip = new CCoinsViewCache(*pcoinsdbview); |
|
|
|
@ -801,17 +814,47 @@ bool AppInit2()
@@ -801,17 +814,47 @@ bool AppInit2()
|
|
|
|
|
if (fReindex) |
|
|
|
|
pblocktree->WriteReindexing(true); |
|
|
|
|
|
|
|
|
|
if (!LoadBlockIndex()) |
|
|
|
|
return InitError(_("Error loading block database")); |
|
|
|
|
if (!LoadBlockIndex()) { |
|
|
|
|
strLoadError = _("Error loading block database"); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Initialize the block index (no-op if non-empty database was already loaded)
|
|
|
|
|
if (!InitBlockIndex()) |
|
|
|
|
return InitError(_("Error initializing block database")); |
|
|
|
|
if (!InitBlockIndex()) { |
|
|
|
|
strLoadError = _("Error initializing block database"); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
uiInterface.InitMessage(_("Verifying block database integrity...")); |
|
|
|
|
if (!VerifyDB()) { |
|
|
|
|
strLoadError = _("Corrupted block database detected"); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} catch(std::exception &e) { |
|
|
|
|
strLoadError = _("Error opening block database"); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fLoaded = true; |
|
|
|
|
} while(false); |
|
|
|
|
|
|
|
|
|
if (!VerifyDB()) |
|
|
|
|
return InitError(_("Corrupted block database detected. Please restart the client with -reindex.")); |
|
|
|
|
if (!fLoaded) { |
|
|
|
|
// first suggest a reindex
|
|
|
|
|
if (!fReset) { |
|
|
|
|
bool fRet = uiInterface.ThreadSafeMessageBox( |
|
|
|
|
strLoadError + ".\n" + _("Do you want to rebuild the block database now?"), |
|
|
|
|
"", CClientUIInterface::MSG_ERROR | CClientUIInterface::BTN_ABORT); |
|
|
|
|
if (fRet) { |
|
|
|
|
fReindex = true; |
|
|
|
|
fRequestShutdown = false; |
|
|
|
|
} else { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
return InitError(strLoadError); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (mapArgs.count("-txindex") && fTxIndex != GetBoolArg("-txindex", false)) |
|
|
|
|
return InitError(_("You need to rebuild the databases using -reindex to change -txindex")); |
|
|
|
|