mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-04-13 17:18:00 +02:00
coins: introduce CoinsViewOverlay
Introduce `CoinsViewOverlay`, a `CCoinsViewCache` subclass that reads coins without mutating the underlying cache via `FetchCoin()`. Use `PeekCoin()` to look up a Coin through a stack of `CCoinsViewCache` layers without populating parent caches. This prevents the main cache from caching inputs pulled from disk for a block that has not yet been fully validated. Once `Flush()` is called on the view, these inputs will be added as spent to `coinsCache` in the main cache via `BatchWrite()`. This is the foundation for async input fetching, where worker threads must not mutate shared state. Co-authored-by: l0rinc <pap.lorinc@gmail.com>
This commit is contained in:
@@ -374,7 +374,11 @@ FUZZ_TARGET(coinscache_sim)
|
||||
[&]() { // Add a cache level (if not already at the max).
|
||||
if (caches.size() != MAX_CACHES) {
|
||||
// Apply to real caches.
|
||||
caches.emplace_back(new CCoinsViewCache(&*caches.back(), /*deterministic=*/true));
|
||||
if (provider.ConsumeBool()) {
|
||||
caches.emplace_back(new CCoinsViewCache(&*caches.back(), /*deterministic=*/true));
|
||||
} else {
|
||||
caches.emplace_back(new CoinsViewOverlay(&*caches.back(), /*deterministic=*/true));
|
||||
}
|
||||
// Apply to simulation data.
|
||||
sim_caches[caches.size()].Wipe();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user