@@ -4434,15 +4434,17 @@ bool CVerifyDB::VerifyDB(
4434
4434
{
4435
4435
AssertLockHeld (cs_main);
4436
4436
4437
- if (chainstate.m_chain .Tip () == nullptr || chainstate.m_chain .Tip ()->pprev == nullptr )
4437
+ if (chainstate.m_chain .Tip () == nullptr || chainstate.m_chain .Tip ()->pprev == nullptr ) {
4438
4438
return true ;
4439
+ }
4439
4440
4440
4441
// begin tx and let it rollback
4441
4442
auto dbTx = evoDb.BeginTransaction ();
4442
4443
4443
4444
// Verify blocks in the best chain
4444
- if (nCheckDepth <= 0 || nCheckDepth > chainstate.m_chain .Height ())
4445
+ if (nCheckDepth <= 0 || nCheckDepth > chainstate.m_chain .Height ()) {
4445
4446
nCheckDepth = chainstate.m_chain .Height ();
4447
+ }
4446
4448
nCheckLevel = std::max (0 , std::min (4 , nCheckLevel));
4447
4449
LogPrintf (" Verifying last %i blocks at level %i\n " , nCheckDepth, nCheckLevel);
4448
4450
CCoinsViewCache coins (&coinsview);
@@ -4457,14 +4459,15 @@ bool CVerifyDB::VerifyDB(
4457
4459
4458
4460
for (pindex = chainstate.m_chain .Tip (); pindex && pindex->pprev ; pindex = pindex->pprev ) {
4459
4461
const int percentageDone = std::max (1 , std::min (99 , (int )(((double )(chainstate.m_chain .Height () - pindex->nHeight )) / (double )nCheckDepth * (nCheckLevel >= 4 ? 50 : 100 ))));
4460
- if (reportDone < percentageDone/ 10 ) {
4462
+ if (reportDone < percentageDone / 10 ) {
4461
4463
// report every 10% step
4462
4464
LogPrintf (" [%d%%]..." , percentageDone); /* Continued */
4463
- reportDone = percentageDone/ 10 ;
4465
+ reportDone = percentageDone / 10 ;
4464
4466
}
4465
4467
uiInterface.ShowProgress (_ (" Verifying blocks…" ).translated , percentageDone, false );
4466
- if (pindex->nHeight <= chainstate.m_chain .Height ()- nCheckDepth)
4468
+ if (pindex->nHeight <= chainstate.m_chain .Height () - nCheckDepth) {
4467
4469
break ;
4470
+ }
4468
4471
if ((fPruneMode || is_snapshot_cs) && !(pindex->nStatus & BLOCK_HAVE_DATA)) {
4469
4472
// If pruning or running under an assumeutxo snapshot, only go
4470
4473
// back as far as we have data.
@@ -4473,12 +4476,14 @@ bool CVerifyDB::VerifyDB(
4473
4476
}
4474
4477
CBlock block;
4475
4478
// check level 0: read from disk
4476
- if (!ReadBlockFromDisk (block, pindex, consensus_params))
4479
+ if (!ReadBlockFromDisk (block, pindex, consensus_params)) {
4477
4480
return error (" VerifyDB(): *** ReadBlockFromDisk failed at %d, hash=%s" , pindex->nHeight , pindex->GetBlockHash ().ToString ());
4481
+ }
4478
4482
// check level 1: verify block validity
4479
- if (nCheckLevel >= 1 && !CheckBlock (block, state, consensus_params))
4483
+ if (nCheckLevel >= 1 && !CheckBlock (block, state, consensus_params)) {
4480
4484
return error (" %s: *** found bad block at %d, hash=%s (%s)\n " , __func__,
4481
4485
pindex->nHeight , pindex->GetBlockHash ().ToString (), state.ToString ());
4486
+ }
4482
4487
// check level 2: verify undo validity
4483
4488
if (nCheckLevel >= 2 && pindex) {
4484
4489
CBlockUndo undo;
@@ -4506,8 +4511,9 @@ bool CVerifyDB::VerifyDB(
4506
4511
}
4507
4512
if (ShutdownRequested ()) return true ;
4508
4513
}
4509
- if (pindexFailure)
4514
+ if (pindexFailure) {
4510
4515
return error (" VerifyDB(): *** coin database inconsistencies found (last %i blocks, %i good transactions before that)\n " , chainstate.m_chain .Height () - pindexFailure->nHeight + 1 , nGoodTransactions);
4516
+ }
4511
4517
4512
4518
// store block count as we move pindex at check level >= 4
4513
4519
int block_count = chainstate.m_chain .Height () - pindex->nHeight ;
@@ -4516,10 +4522,10 @@ bool CVerifyDB::VerifyDB(
4516
4522
if (nCheckLevel >= 4 ) {
4517
4523
while (pindex != chainstate.m_chain .Tip ()) {
4518
4524
const int percentageDone = std::max (1 , std::min (99 , 100 - (int )(((double )(chainstate.m_chain .Height () - pindex->nHeight )) / (double )nCheckDepth * 50 )));
4519
- if (reportDone < percentageDone/ 10 ) {
4525
+ if (reportDone < percentageDone / 10 ) {
4520
4526
// report every 10% step
4521
4527
LogPrintf (" [%d%%]..." , percentageDone); /* Continued */
4522
- reportDone = percentageDone/ 10 ;
4528
+ reportDone = percentageDone / 10 ;
4523
4529
}
4524
4530
uiInterface.ShowProgress (_ (" Verifying blocks…" ).translated , percentageDone, false );
4525
4531
pindex = chainstate.m_chain .Next (pindex);
0 commit comments