@@ -4081,6 +4081,7 @@ bool CVerifyDB::VerifyDB(
4081
4081
int nGoodTransactions = 0 ;
4082
4082
BlockValidationState state;
4083
4083
int reportDone = 0 ;
4084
+ bool skipped_l3_checks{false };
4084
4085
LogPrintf (" [0%%]..." ); /* Continued */
4085
4086
4086
4087
const bool is_snapshot_cs{!chainstate.m_from_snapshot_blockhash };
@@ -4124,30 +4125,36 @@ bool CVerifyDB::VerifyDB(
4124
4125
// check level 3: check for inconsistencies during memory-only disconnect of tip blocks
4125
4126
size_t curr_coins_usage = coins.DynamicMemoryUsage () + chainstate.CoinsTip ().DynamicMemoryUsage ();
4126
4127
4127
- if (nCheckLevel >= 3 && curr_coins_usage <= chainstate.m_coinstip_cache_size_bytes ) {
4128
- assert (coins.GetBestBlock () == pindex->GetBlockHash ());
4129
- DisconnectResult res = chainstate.DisconnectBlock (block, pindex, coins);
4130
- if (res == DISCONNECT_FAILED) {
4131
- return error (" VerifyDB(): *** irrecoverable inconsistency in block data at %d, hash=%s" , pindex->nHeight , pindex->GetBlockHash ().ToString ());
4132
- }
4133
- if (res == DISCONNECT_UNCLEAN) {
4134
- nGoodTransactions = 0 ;
4135
- pindexFailure = pindex;
4128
+ if (nCheckLevel >= 3 ) {
4129
+ if (curr_coins_usage <= chainstate.m_coinstip_cache_size_bytes ) {
4130
+ assert (coins.GetBestBlock () == pindex->GetBlockHash ());
4131
+ DisconnectResult res = chainstate.DisconnectBlock (block, pindex, coins);
4132
+ if (res == DISCONNECT_FAILED) {
4133
+ return error (" VerifyDB(): *** irrecoverable inconsistency in block data at %d, hash=%s" , pindex->nHeight , pindex->GetBlockHash ().ToString ());
4134
+ }
4135
+ if (res == DISCONNECT_UNCLEAN) {
4136
+ nGoodTransactions = 0 ;
4137
+ pindexFailure = pindex;
4138
+ } else {
4139
+ nGoodTransactions += block.vtx .size ();
4140
+ }
4136
4141
} else {
4137
- nGoodTransactions += block. vtx . size () ;
4142
+ skipped_l3_checks = true ;
4138
4143
}
4139
4144
}
4140
4145
if (ShutdownRequested ()) return true ;
4141
4146
}
4142
4147
if (pindexFailure) {
4143
4148
return error (" VerifyDB(): *** coin database inconsistencies found (last %i blocks, %i good transactions before that)\n " , chainstate.m_chain .Height () - pindexFailure->nHeight + 1 , nGoodTransactions);
4144
4149
}
4145
-
4150
+ if (skipped_l3_checks) {
4151
+ LogPrintf (" Skipped verification of level >=3 (insufficient database cache size). Consider increasing -dbcache.\n " );
4152
+ }
4146
4153
// store block count as we move pindex at check level >= 4
4147
4154
int block_count = chainstate.m_chain .Height () - pindex->nHeight ;
4148
4155
4149
4156
// check level 4: try reconnecting blocks
4150
- if (nCheckLevel >= 4 ) {
4157
+ if (nCheckLevel >= 4 && !skipped_l3_checks ) {
4151
4158
while (pindex != chainstate.m_chain .Tip ()) {
4152
4159
const int percentageDone = std::max (1 , std::min (99 , 100 - (int )(((double )(chainstate.m_chain .Height () - pindex->nHeight )) / (double )nCheckDepth * 50 )));
4153
4160
if (reportDone < percentageDone / 10 ) {
0 commit comments