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()
320320void CCoinsViewCache::SanityCheck () const
321321{
322322 size_t recomputed_usage = 0 ;
323+ size_t count_flagged = 0 ;
323324 for (const auto & [_, entry] : cacheCoins) {
324325 unsigned attr = 0 ;
325326 if (entry.IsDirty ()) attr |= 1 ;
@@ -330,7 +331,22 @@ void CCoinsViewCache::SanityCheck() const
330331
331332 // Recompute cachedCoinsUsage.
332333 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;
333348 }
349+ assert (count_linked == count_flagged);
334350 assert (recomputed_usage == cachedCoinsUsage);
335351}
336352
You can’t perform that action at this time.
0 commit comments