mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-04-26 14:59:16 +02:00
validation: don't reallocate cache for short-lived CCoinsViewCache
A few temporary `CCoinsViewCache`'s are destructed right after the `Flush()`, therefore it is not necessary to call `ReallocateCache` to recreate them right before they're killed anyway. * `Flush()` - retains existing functionality; * `Flush(/*will_reuse_cache=*/false)` - skips destruction and reallocation of the parent cache since it will soon go out of scope anyway; For the `will_reuse_cache` parameter we want to see exactly which ones will reallocate memory and which won't - since both can be valid usages. This change was based on a subset of https://github.com/bitcoin/bitcoin/pull/28945. Co-authored-by: Martin Ankerl <martin.ankerl@gmail.com>
This commit is contained in:
@@ -74,7 +74,7 @@ void TestCoinsView(FuzzedDataProvider& fuzzed_data_provider, CCoinsView& backend
|
||||
}
|
||||
},
|
||||
[&] {
|
||||
(void)coins_view_cache.Flush();
|
||||
(void)coins_view_cache.Flush(/*will_reuse_cache=*/fuzzed_data_provider.ConsumeBool());
|
||||
},
|
||||
[&] {
|
||||
(void)coins_view_cache.Sync();
|
||||
|
||||
@@ -392,7 +392,7 @@ FUZZ_TARGET(coinscache_sim)
|
||||
// Apply to simulation data.
|
||||
flush();
|
||||
// Apply to real caches.
|
||||
caches.back()->Flush();
|
||||
caches.back()->Flush(/*will_reuse_cache=*/provider.ConsumeBool());
|
||||
},
|
||||
|
||||
[&]() { // Sync.
|
||||
@@ -402,14 +402,6 @@ FUZZ_TARGET(coinscache_sim)
|
||||
caches.back()->Sync();
|
||||
},
|
||||
|
||||
[&]() { // Flush + ReallocateCache.
|
||||
// Apply to simulation data.
|
||||
flush();
|
||||
// Apply to real caches.
|
||||
caches.back()->Flush();
|
||||
caches.back()->ReallocateCache();
|
||||
},
|
||||
|
||||
[&]() { // GetCacheSize
|
||||
(void)caches.back()->GetCacheSize();
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user