![]() |
Bitcoin Core 31.0.0
P2P Digital Currency
|
CCoinsViewCache overlay that avoids populating/mutating parent cache layers on cache misses. More...
#include <coins.h>
Public Member Functions | |
| CCoinsViewCache (CCoinsView *baseIn, bool deterministic=false) | |
| CCoinsViewCache (const CCoinsViewCache &)=delete | |
| By deleting the copy constructor, we prevent accidentally using it when one intends to create a cache on top of a base cache. | |
| Public Member Functions inherited from CCoinsViewCache | |
| CCoinsViewCache (CCoinsView *baseIn, bool deterministic=false) | |
| CCoinsViewCache (const CCoinsViewCache &)=delete | |
| By deleting the copy constructor, we prevent accidentally using it when one intends to create a cache on top of a base cache. | |
| std::optional< Coin > | GetCoin (const COutPoint &outpoint) const override |
| std::optional< Coin > | PeekCoin (const COutPoint &outpoint) const override |
| bool | HaveCoin (const COutPoint &outpoint) const override |
| uint256 | GetBestBlock () const override |
| Retrieve the block hash whose state this CCoinsView currently represents. | |
| void | SetBestBlock (const uint256 &hashBlock) |
| void | BatchWrite (CoinsViewCacheCursor &cursor, const uint256 &hashBlock) override |
| std::unique_ptr< CCoinsViewCursor > | Cursor () const override |
| Get a cursor to iterate over the whole state. | |
| bool | HaveCoinInCache (const COutPoint &outpoint) const |
| Check if we have the given utxo already loaded in this cache. | |
| const Coin & | AccessCoin (const COutPoint &output) const |
| Return a reference to Coin in the cache, or coinEmpty if not found. | |
| void | AddCoin (const COutPoint &outpoint, Coin &&coin, bool possible_overwrite) |
| Add a coin. | |
| void | EmplaceCoinInternalDANGER (COutPoint &&outpoint, Coin &&coin) |
| Emplace a coin into cacheCoins without performing any checks, marking the emplaced coin as dirty. | |
| bool | SpendCoin (const COutPoint &outpoint, Coin *moveto=nullptr) |
| Spend a coin. | |
| void | Flush (bool reallocate_cache=true) |
| Push the modifications applied to this cache to its base and wipe local state. | |
| void | Sync () |
| Push the modifications applied to this cache to its base while retaining the contents of this cache (except for spent coins, which we erase). | |
| void | Uncache (const COutPoint &outpoint) |
| Removes the UTXO with the given outpoint from the cache, if it is not modified. | |
| unsigned int | GetCacheSize () const |
| Size of the cache (in number of transaction outputs). | |
| size_t | GetDirtyCount () const noexcept |
| Number of dirty cache entries (transaction outputs). | |
| size_t | DynamicMemoryUsage () const |
| Calculate the size of the cache (in bytes). | |
| bool | HaveInputs (const CTransaction &tx) const |
| Check whether all prevouts of the transaction are present in the UTXO set represented by this view. | |
| void | ReallocateCache () |
| void | SanityCheck () const |
| Run an internal sanity check on the cache data structure. */. | |
| ResetGuard | CreateResetGuard () noexcept |
| Create a scoped guard that will call Reset() on this cache when it goes out of scope. | |
| Public Member Functions inherited from CCoinsViewBacked | |
| CCoinsViewBacked (CCoinsView *viewIn) | |
| std::vector< uint256 > | GetHeadBlocks () const override |
| void | SetBackend (CCoinsView &viewIn) |
| size_t | EstimateSize () const override |
| Estimate database size (0 if not implemented). | |
| Public Member Functions inherited from CCoinsView | |
| virtual | ~CCoinsView ()=default |
| As we use CCoinsViews polymorphically, have a virtual destructor. | |
Private Member Functions | |
| std::optional< Coin > | FetchCoinFromBase (const COutPoint &outpoint) const override |
Additional Inherited Members | |
| Protected Member Functions inherited from CCoinsViewCache | |
| void | Reset () noexcept |
| Discard all modifications made to this cache without flushing to the base view. | |
| Protected Attributes inherited from CCoinsViewCache | |
| uint256 | hashBlock |
| Make mutable so that we can "fill the cache" even from Get-methods declared as "const". | |
| CCoinsMapMemoryResource | m_cache_coins_memory_resource {} |
| CoinsCachePair | m_sentinel |
| CCoinsMap | cacheCoins |
| size_t | cachedCoinsUsage {0} |
| size_t | m_dirty_count {0} |
| Protected Attributes inherited from CCoinsViewBacked | |
| CCoinsView * | base |
CCoinsViewCache overlay that avoids populating/mutating parent cache layers on cache misses.
This is achieved by fetching coins from the base view using PeekCoin() instead of GetCoin(), so intermediate CCoinsViewCache layers are not filled.
Used during ConnectBlock() as an ephemeral, resettable top-level view that is flushed only on success, so invalid blocks don't pollute the underlying cache.
| CCoinsViewCache::CCoinsViewCache | ( | CCoinsView * | baseIn, |
| bool | deterministic = false ) |
|
delete |
By deleting the copy constructor, we prevent accidentally using it when one intends to create a cache on top of a base cache.
|
inlineoverrideprivatevirtual |
Reimplemented from CCoinsViewCache.