coins: introduce CCoinsViewCache::ResetGuard

CCoinsViewCache::CreateResetGuard returns a guard that calls
Reset on the cache when the guard goes out of scope.
This RAII pattern ensures the cache is always properly reset
when it leaves current scope.

Co-authored-by: l0rinc <pap.lorinc@gmail.com>
Co-authored-by: sedited <seb.kung@gmail.com>
This commit is contained in:
Andrew Toth
2026-01-24 13:59:54 -05:00
parent 041758f5ed
commit 8fb6043231
4 changed files with 85 additions and 0 deletions

View File

@@ -401,6 +401,14 @@ FUZZ_TARGET(coinscache_sim)
caches.back()->Sync();
},
[&]() { // Reset.
sim_caches[caches.size()].Wipe();
// Apply to real caches.
{
const auto reset_guard{caches.back()->CreateResetGuard()};
}
},
[&]() { // GetCacheSize
(void)caches.back()->GetCacheSize();
},