X-Git-Url: https://git.novaco.in/?p=novacoin.git;a=blobdiff_plain;f=src%2Finit.cpp;h=b1dec89825acb92fc03145b461bbc370cb5ebea4;hp=296369d2c6743c04916be7b59650f8cf3275bcaa;hb=f94158ea104e435166e6e6074f0d941b903267eb;hpb=29fb6d5ed06009472aeef317ff088974b0d281aa diff --git a/src/init.cpp b/src/init.cpp index 296369d..b1dec89 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -86,6 +86,7 @@ void Shutdown(void* parg) if (fFirstThread) { fShutdown = true; + fRequestShutdown = true; nTransactionsUpdated++; // CTxDB().Close(); bitdb.Flush(false); @@ -766,12 +767,35 @@ bool AppInit2() return false; } - uiInterface.InitMessage(_("Loading block index...")); + printf("Loading block index...\n"); - nStart = GetTimeMillis(); - if (!LoadBlockIndex()) - return InitError(_("Error loading blkindex.dat")); + bool fLoaded = false; + while (!fLoaded) { + std::string strLoadError; + uiInterface.InitMessage(_("Loading block index...")); + + nStart = GetTimeMillis(); + do { + try { + UnloadBlockIndex(); + + if (!LoadBlockIndex()) { + strLoadError = _("Error loading block database"); + break; + } + } catch(std::exception &e) { + strLoadError = _("Error opening block database"); + break; + } + + fLoaded = true; + } while(false); + if (!fLoaded) { + // TODO: suggest reindex here + return InitError(strLoadError); + } + } // as LoadBlockIndex can take several minutes, it's possible the user // requested to kill bitcoin-qt during the last operation. If so, exit.