mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-05-23 04:16:52 +02:00
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:
@@ -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();
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user