@@ -3840,12 +3840,14 @@ bool CVerifyDB::VerifyDB(
3840
3840
{
3841
3841
AssertLockHeld (cs_main);
3842
3842
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 ) {
3844
3844
return true ;
3845
+ }
3845
3846
3846
3847
// Verify blocks in the best chain
3847
- if (nCheckDepth <= 0 || nCheckDepth > chainstate.m_chain .Height ())
3848
+ if (nCheckDepth <= 0 || nCheckDepth > chainstate.m_chain .Height ()) {
3848
3849
nCheckDepth = chainstate.m_chain .Height ();
3850
+ }
3849
3851
nCheckLevel = std::max (0 , std::min (4 , nCheckLevel));
3850
3852
LogPrintf (" Verifying last %i blocks at level %i\n " , nCheckDepth, nCheckLevel);
3851
3853
CCoinsViewCache coins (&coinsview);
@@ -3860,14 +3862,15 @@ bool CVerifyDB::VerifyDB(
3860
3862
3861
3863
for (pindex = chainstate.m_chain .Tip (); pindex && pindex->pprev ; pindex = pindex->pprev ) {
3862
3864
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 ) {
3864
3866
// report every 10% step
3865
3867
LogPrintf (" [%d%%]..." , percentageDone); /* Continued */
3866
- reportDone = percentageDone/ 10 ;
3868
+ reportDone = percentageDone / 10 ;
3867
3869
}
3868
3870
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) {
3870
3872
break ;
3873
+ }
3871
3874
if ((fPruneMode || is_snapshot_cs) && !(pindex->nStatus & BLOCK_HAVE_DATA)) {
3872
3875
// If pruning or running under an assumeutxo snapshot, only go
3873
3876
// back as far as we have data.
@@ -3876,12 +3879,14 @@ bool CVerifyDB::VerifyDB(
3876
3879
}
3877
3880
CBlock block;
3878
3881
// check level 0: read from disk
3879
- if (!ReadBlockFromDisk (block, pindex, consensus_params))
3882
+ if (!ReadBlockFromDisk (block, pindex, consensus_params)) {
3880
3883
return error (" VerifyDB(): *** ReadBlockFromDisk failed at %d, hash=%s" , pindex->nHeight , pindex->GetBlockHash ().ToString ());
3884
+ }
3881
3885
// check level 1: verify block validity
3882
- if (nCheckLevel >= 1 && !CheckBlock (block, state, consensus_params))
3886
+ if (nCheckLevel >= 1 && !CheckBlock (block, state, consensus_params)) {
3883
3887
return error (" %s: *** found bad block at %d, hash=%s (%s)\n " , __func__,
3884
3888
pindex->nHeight , pindex->GetBlockHash ().ToString (), state.ToString ());
3889
+ }
3885
3890
// check level 2: verify undo validity
3886
3891
if (nCheckLevel >= 2 && pindex) {
3887
3892
CBlockUndo undo;
@@ -3909,8 +3914,9 @@ bool CVerifyDB::VerifyDB(
3909
3914
}
3910
3915
if (ShutdownRequested ()) return true ;
3911
3916
}
3912
- if (pindexFailure)
3917
+ if (pindexFailure) {
3913
3918
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
+ }
3914
3920
3915
3921
// store block count as we move pindex at check level >= 4
3916
3922
int block_count = chainstate.m_chain .Height () - pindex->nHeight ;
@@ -3919,10 +3925,10 @@ bool CVerifyDB::VerifyDB(
3919
3925
if (nCheckLevel >= 4 ) {
3920
3926
while (pindex != chainstate.m_chain .Tip ()) {
3921
3927
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 ) {
3923
3929
// report every 10% step
3924
3930
LogPrintf (" [%d%%]..." , percentageDone); /* Continued */
3925
- reportDone = percentageDone/ 10 ;
3931
+ reportDone = percentageDone / 10 ;
3926
3932
}
3927
3933
uiInterface.ShowProgress (_ (" Verifying blocks…" ).translated , percentageDone, false );
3928
3934
pindex = chainstate.m_chain .Next (pindex);
0 commit comments