File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -320,6 +320,7 @@ void CCoinsViewCache::ReallocateCache()
320
320
void CCoinsViewCache::SanityCheck () const
321
321
{
322
322
size_t recomputed_usage = 0 ;
323
+ size_t count_flagged = 0 ;
323
324
for (const auto & [_, entry] : cacheCoins) {
324
325
unsigned attr = 0 ;
325
326
if (entry.IsDirty ()) attr |= 1 ;
@@ -330,7 +331,22 @@ void CCoinsViewCache::SanityCheck() const
330
331
331
332
// Recompute cachedCoinsUsage.
332
333
recomputed_usage += entry.coin .DynamicMemoryUsage ();
334
+
335
+ // Count the number of entries we expect in the linked list.
336
+ if (entry.IsDirty () || entry.IsFresh ()) ++count_flagged;
337
+ }
338
+ // Iterate over the linked list of flagged entries.
339
+ size_t count_linked = 0 ;
340
+ for (auto it = m_sentinel.second .Next (); it != &m_sentinel; it = it->second .Next ()) {
341
+ // Verify linked list integrity.
342
+ assert (it->second .Next ()->second .Prev () == it);
343
+ assert (it->second .Prev ()->second .Next () == it);
344
+ // Verify they are actually flagged.
345
+ assert (it->second .IsDirty () || it->second .IsFresh ());
346
+ // Count the number of entries actually in the list.
347
+ ++count_linked;
333
348
}
349
+ assert (count_linked == count_flagged);
334
350
assert (recomputed_usage == cachedCoinsUsage);
335
351
}
336
352
You can’t perform that action at this time.
0 commit comments