@@ -4104,7 +4104,7 @@ CVerifyDB::~CVerifyDB()
4104
4104
bool CVerifyDB::VerifyDB (
4105
4105
CChainState& chainstate,
4106
4106
const CChainParams& chainparams,
4107
- CCoinsView* coinsview,
4107
+ CCoinsView& coinsview,
4108
4108
int nCheckLevel, int nCheckDepth)
4109
4109
{
4110
4110
AssertLockHeld (cs_main);
@@ -4118,13 +4118,16 @@ bool CVerifyDB::VerifyDB(
4118
4118
nCheckDepth = chainstate.m_chain .Height ();
4119
4119
nCheckLevel = std::max (0 , std::min (4 , nCheckLevel));
4120
4120
LogPrintf (" Verifying last %i blocks at level %i\n " , nCheckDepth, nCheckLevel);
4121
- CCoinsViewCache coins (coinsview);
4121
+ CCoinsViewCache coins (& coinsview);
4122
4122
CBlockIndex* pindex;
4123
4123
CBlockIndex* pindexFailure = nullptr ;
4124
4124
int nGoodTransactions = 0 ;
4125
4125
BlockValidationState state;
4126
4126
int reportDone = 0 ;
4127
4127
LogPrintf (" [0%%]..." ); /* Continued */
4128
+
4129
+ bool is_snapshot_cs = !chainstate.m_from_snapshot_blockhash .IsNull ();
4130
+
4128
4131
for (pindex = chainstate.m_chain .Tip (); pindex && pindex->pprev ; pindex = pindex->pprev ) {
4129
4132
const int percentageDone = std::max (1 , std::min (99 , (int )(((double )(chainstate.m_chain .Height () - pindex->nHeight )) / (double )nCheckDepth * (nCheckLevel >= 4 ? 50 : 100 ))));
4130
4133
if (reportDone < percentageDone/10 ) {
@@ -4135,8 +4138,9 @@ bool CVerifyDB::VerifyDB(
4135
4138
uiInterface.ShowProgress (_ (" Verifying blocks..." ).translated , percentageDone, false );
4136
4139
if (pindex->nHeight <= chainstate.m_chain .Height ()-nCheckDepth)
4137
4140
break ;
4138
- if (fPruneMode && !(pindex->nStatus & BLOCK_HAVE_DATA)) {
4139
- // If pruning, only go back as far as we have data.
4141
+ if ((fPruneMode || is_snapshot_cs) && !(pindex->nStatus & BLOCK_HAVE_DATA)) {
4142
+ // If pruning or running under an assumeutxo snapshot, only go
4143
+ // back as far as we have data.
4140
4144
LogPrintf (" VerifyDB(): block verification stopping at height %d (pruning, no data)\n " , pindex->nHeight );
4141
4145
break ;
4142
4146
}
@@ -4158,9 +4162,9 @@ bool CVerifyDB::VerifyDB(
4158
4162
}
4159
4163
}
4160
4164
// check level 3: check for inconsistencies during memory-only disconnect of tip blocks
4161
- int64_t curr_coins_usage = coins.DynamicMemoryUsage () + chainstate.CoinsTip ().DynamicMemoryUsage ();
4165
+ size_t curr_coins_usage = coins.DynamicMemoryUsage () + chainstate.CoinsTip ().DynamicMemoryUsage ();
4162
4166
4163
- if (nCheckLevel >= 3 && static_cast < unsigned long >( curr_coins_usage) <= chainstate.m_coinstip_cache_size_bytes ) {
4167
+ if (nCheckLevel >= 3 && curr_coins_usage <= chainstate.m_coinstip_cache_size_bytes ) {
4164
4168
assert (coins.GetBestBlock () == pindex->GetBlockHash ());
4165
4169
DisconnectResult res = chainstate.DisconnectBlock (block, pindex, coins);
4166
4170
if (res == DISCONNECT_FAILED) {
0 commit comments