Skip to content

Commit fa79916

Browse files
author
MarcoFalke
committed
Fixup style of VerifyDB
1 parent fa462ea commit fa79916

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

src/validation.cpp

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3840,12 +3840,14 @@ bool CVerifyDB::VerifyDB(
38403840
{
38413841
AssertLockHeld(cs_main);
38423842

3843-
if (chainstate.m_chain.Tip() == nullptr || chainstate.m_chain.Tip()->pprev == nullptr)
3843+
if (chainstate.m_chain.Tip() == nullptr || chainstate.m_chain.Tip()->pprev == nullptr) {
38443844
return true;
3845+
}
38453846

38463847
// Verify blocks in the best chain
3847-
if (nCheckDepth <= 0 || nCheckDepth > chainstate.m_chain.Height())
3848+
if (nCheckDepth <= 0 || nCheckDepth > chainstate.m_chain.Height()) {
38483849
nCheckDepth = chainstate.m_chain.Height();
3850+
}
38493851
nCheckLevel = std::max(0, std::min(4, nCheckLevel));
38503852
LogPrintf("Verifying last %i blocks at level %i\n", nCheckDepth, nCheckLevel);
38513853
CCoinsViewCache coins(&coinsview);
@@ -3860,14 +3862,15 @@ bool CVerifyDB::VerifyDB(
38603862

38613863
for (pindex = chainstate.m_chain.Tip(); pindex && pindex->pprev; pindex = pindex->pprev) {
38623864
const int percentageDone = std::max(1, std::min(99, (int)(((double)(chainstate.m_chain.Height() - pindex->nHeight)) / (double)nCheckDepth * (nCheckLevel >= 4 ? 50 : 100))));
3863-
if (reportDone < percentageDone/10) {
3865+
if (reportDone < percentageDone / 10) {
38643866
// report every 10% step
38653867
LogPrintf("[%d%%]...", percentageDone); /* Continued */
3866-
reportDone = percentageDone/10;
3868+
reportDone = percentageDone / 10;
38673869
}
38683870
uiInterface.ShowProgress(_("Verifying blocks…").translated, percentageDone, false);
3869-
if (pindex->nHeight <= chainstate.m_chain.Height()-nCheckDepth)
3871+
if (pindex->nHeight <= chainstate.m_chain.Height() - nCheckDepth) {
38703872
break;
3873+
}
38713874
if ((fPruneMode || is_snapshot_cs) && !(pindex->nStatus & BLOCK_HAVE_DATA)) {
38723875
// If pruning or running under an assumeutxo snapshot, only go
38733876
// back as far as we have data.
@@ -3876,12 +3879,14 @@ bool CVerifyDB::VerifyDB(
38763879
}
38773880
CBlock block;
38783881
// check level 0: read from disk
3879-
if (!ReadBlockFromDisk(block, pindex, consensus_params))
3882+
if (!ReadBlockFromDisk(block, pindex, consensus_params)) {
38803883
return error("VerifyDB(): *** ReadBlockFromDisk failed at %d, hash=%s", pindex->nHeight, pindex->GetBlockHash().ToString());
3884+
}
38813885
// check level 1: verify block validity
3882-
if (nCheckLevel >= 1 && !CheckBlock(block, state, consensus_params))
3886+
if (nCheckLevel >= 1 && !CheckBlock(block, state, consensus_params)) {
38833887
return error("%s: *** found bad block at %d, hash=%s (%s)\n", __func__,
38843888
pindex->nHeight, pindex->GetBlockHash().ToString(), state.ToString());
3889+
}
38853890
// check level 2: verify undo validity
38863891
if (nCheckLevel >= 2 && pindex) {
38873892
CBlockUndo undo;
@@ -3909,8 +3914,9 @@ bool CVerifyDB::VerifyDB(
39093914
}
39103915
if (ShutdownRequested()) return true;
39113916
}
3912-
if (pindexFailure)
3917+
if (pindexFailure) {
39133918
return error("VerifyDB(): *** coin database inconsistencies found (last %i blocks, %i good transactions before that)\n", chainstate.m_chain.Height() - pindexFailure->nHeight + 1, nGoodTransactions);
3919+
}
39143920

39153921
// store block count as we move pindex at check level >= 4
39163922
int block_count = chainstate.m_chain.Height() - pindex->nHeight;
@@ -3919,10 +3925,10 @@ bool CVerifyDB::VerifyDB(
39193925
if (nCheckLevel >= 4) {
39203926
while (pindex != chainstate.m_chain.Tip()) {
39213927
const int percentageDone = std::max(1, std::min(99, 100 - (int)(((double)(chainstate.m_chain.Height() - pindex->nHeight)) / (double)nCheckDepth * 50)));
3922-
if (reportDone < percentageDone/10) {
3928+
if (reportDone < percentageDone / 10) {
39233929
// report every 10% step
39243930
LogPrintf("[%d%%]...", percentageDone); /* Continued */
3925-
reportDone = percentageDone/10;
3931+
reportDone = percentageDone / 10;
39263932
}
39273933
uiInterface.ShowProgress(_("Verifying blocks…").translated, percentageDone, false);
39283934
pindex = chainstate.m_chain.Next(pindex);

0 commit comments

Comments
 (0)