Changeset View
Changeset View
Standalone View
Standalone View
src/validation.cpp
Show First 20 Lines • Show All 4,598 Lines • ▼ Show 20 Lines | bool CVerifyDB::VerifyDB(const Config &config, CCoinsView *coinsview, | ||||
CBlockIndex *pindexFailure = nullptr; | CBlockIndex *pindexFailure = nullptr; | ||||
int nGoodTransactions = 0; | int nGoodTransactions = 0; | ||||
CValidationState state; | CValidationState state; | ||||
int reportDone = 0; | int reportDone = 0; | ||||
LogPrintfToBeContinued("[0%%]..."); | LogPrintfToBeContinued("[0%%]..."); | ||||
for (pindex = ::ChainActive().Tip(); pindex && pindex->pprev; | for (pindex = ::ChainActive().Tip(); pindex && pindex->pprev; | ||||
pindex = pindex->pprev) { | pindex = pindex->pprev) { | ||||
boost::this_thread::interruption_point(); | boost::this_thread::interruption_point(); | ||||
int percentageDone = | const int percentageDone = | ||||
std::max(1, std::min(99, (int)(((double)(::ChainActive().Height() - | std::max(1, std::min(99, (int)(((double)(::ChainActive().Height() - | ||||
pindex->nHeight)) / | pindex->nHeight)) / | ||||
(double)nCheckDepth * | (double)nCheckDepth * | ||||
(nCheckLevel >= 4 ? 50 : 100)))); | (nCheckLevel >= 4 ? 50 : 100)))); | ||||
if (reportDone < percentageDone / 10) { | if (reportDone < percentageDone / 10) { | ||||
// report every 10% step | // report every 10% step | ||||
LogPrintfToBeContinued("[%d%%]...", percentageDone); | LogPrintfToBeContinued("[%d%%]...", percentageDone); | ||||
reportDone = percentageDone / 10; | reportDone = percentageDone / 10; | ||||
} | } | ||||
uiInterface.ShowProgress(_("Verifying blocks...").translated, | uiInterface.ShowProgress(_("Verifying blocks...").translated, | ||||
percentageDone, false); | percentageDone, false); | ||||
▲ Show 20 Lines • Show All 76 Lines • ▼ Show 20 Lines | bool CVerifyDB::VerifyDB(const Config &config, CCoinsView *coinsview, | ||||
// store block count as we move pindex at check level >= 4 | // store block count as we move pindex at check level >= 4 | ||||
int block_count = ::ChainActive().Height() - pindex->nHeight; | int block_count = ::ChainActive().Height() - pindex->nHeight; | ||||
// check level 4: try reconnecting blocks | // check level 4: try reconnecting blocks | ||||
if (nCheckLevel >= 4) { | if (nCheckLevel >= 4) { | ||||
while (pindex != ::ChainActive().Tip()) { | while (pindex != ::ChainActive().Tip()) { | ||||
boost::this_thread::interruption_point(); | boost::this_thread::interruption_point(); | ||||
uiInterface.ShowProgress( | const int percentageDone = std::max( | ||||
_("Verifying blocks...").translated, | 1, std::min(99, 100 - int(double(::ChainActive().Height() - | ||||
std::max( | pindex->nHeight) / | ||||
1, std::min(99, | double(nCheckDepth) * 50))); | ||||
100 - (int)(((double)(::ChainActive().Height() - | if (reportDone < percentageDone / 10) { | ||||
pindex->nHeight)) / | // report every 10% step | ||||
(double)nCheckDepth * 50))), | LogPrintfToBeContinued("[%d%%]...", percentageDone); | ||||
false); | reportDone = percentageDone / 10; | ||||
} | |||||
uiInterface.ShowProgress(_("Verifying blocks...").translated, | |||||
percentageDone, false); | |||||
pindex = ::ChainActive().Next(pindex); | pindex = ::ChainActive().Next(pindex); | ||||
CBlock block; | CBlock block; | ||||
if (!ReadBlockFromDisk(block, pindex, consensusParams)) { | if (!ReadBlockFromDisk(block, pindex, consensusParams)) { | ||||
return error( | return error( | ||||
"VerifyDB(): *** ReadBlockFromDisk failed at %d, hash=%s", | "VerifyDB(): *** ReadBlockFromDisk failed at %d, hash=%s", | ||||
pindex->nHeight, pindex->GetBlockHash().ToString()); | pindex->nHeight, pindex->GetBlockHash().ToString()); | ||||
} | } | ||||
if (!::ChainstateActive().ConnectBlock( | if (!::ChainstateActive().ConnectBlock( | ||||
▲ Show 20 Lines • Show All 956 Lines • Show Last 20 Lines |