|
|
@ -82,6 +82,7 @@ void Shutdown(void* parg) |
|
|
|
if (fFirstThread) |
|
|
|
if (fFirstThread) |
|
|
|
{ |
|
|
|
{ |
|
|
|
fShutdown = true; |
|
|
|
fShutdown = true; |
|
|
|
|
|
|
|
fRequestShutdown = true; |
|
|
|
nTransactionsUpdated++; |
|
|
|
nTransactionsUpdated++; |
|
|
|
bitdb.Flush(false); |
|
|
|
bitdb.Flush(false); |
|
|
|
{ |
|
|
|
{ |
|
|
@ -791,9 +792,21 @@ bool AppInit2() |
|
|
|
nTotalCache -= nCoinDBCache; |
|
|
|
nTotalCache -= nCoinDBCache; |
|
|
|
nCoinCacheSize = nTotalCache / 300; // coins in memory require around 300 bytes
|
|
|
|
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...")); |
|
|
|
uiInterface.InitMessage(_("Loading block index...")); |
|
|
|
|
|
|
|
|
|
|
|
nStart = GetTimeMillis(); |
|
|
|
nStart = GetTimeMillis(); |
|
|
|
|
|
|
|
do { |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
UnloadBlockIndex(); |
|
|
|
|
|
|
|
delete pcoinsTip; |
|
|
|
|
|
|
|
delete pcoinsdbview; |
|
|
|
|
|
|
|
delete pblocktree; |
|
|
|
|
|
|
|
|
|
|
|
pblocktree = new CBlockTreeDB(nBlockTreeDBCache, false, fReindex); |
|
|
|
pblocktree = new CBlockTreeDB(nBlockTreeDBCache, false, fReindex); |
|
|
|
pcoinsdbview = new CCoinsViewDB(nCoinDBCache, false, fReindex); |
|
|
|
pcoinsdbview = new CCoinsViewDB(nCoinDBCache, false, fReindex); |
|
|
|
pcoinsTip = new CCoinsViewCache(*pcoinsdbview); |
|
|
|
pcoinsTip = new CCoinsViewCache(*pcoinsdbview); |
|
|
@ -801,17 +814,47 @@ bool AppInit2() |
|
|
|
if (fReindex) |
|
|
|
if (fReindex) |
|
|
|
pblocktree->WriteReindexing(true); |
|
|
|
pblocktree->WriteReindexing(true); |
|
|
|
|
|
|
|
|
|
|
|
if (!LoadBlockIndex()) |
|
|
|
if (!LoadBlockIndex()) { |
|
|
|
return InitError(_("Error loading block database")); |
|
|
|
strLoadError = _("Error loading block database"); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Initialize the block index (no-op if non-empty database was already loaded)
|
|
|
|
// Initialize the block index (no-op if non-empty database was already loaded)
|
|
|
|
if (!InitBlockIndex()) |
|
|
|
if (!InitBlockIndex()) { |
|
|
|
return InitError(_("Error initializing block database")); |
|
|
|
strLoadError = _("Error initializing block database"); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
uiInterface.InitMessage(_("Verifying block database integrity...")); |
|
|
|
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()) |
|
|
|
if (!fLoaded) { |
|
|
|
return InitError(_("Corrupted block database detected. Please restart the client with -reindex.")); |
|
|
|
// 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)) |
|
|
|
if (mapArgs.count("-txindex") && fTxIndex != GetBoolArg("-txindex", false)) |
|
|
|
return InitError(_("You need to rebuild the databases using -reindex to change -txindex")); |
|
|
|
return InitError(_("You need to rebuild the databases using -reindex to change -txindex")); |
|
|
|