![]() |
Bitcoin Core 30.99.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. More... | |
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. More... | |
| std::optional< Coin > | GetCoin (const COutPoint &outpoint) const override |
| Retrieve the Coin (unspent transaction output) for a given outpoint. More... | |
| std::optional< Coin > | PeekCoin (const COutPoint &outpoint) const override |
| Retrieve the Coin (unspent transaction output) for a given outpoint, without caching results. More... | |
| bool | HaveCoin (const COutPoint &outpoint) const override |
| Just check whether a given outpoint is unspent. More... | |
| uint256 | GetBestBlock () const override |
| Retrieve the block hash whose state this CCoinsView currently represents. More... | |
| void | SetBestBlock (const uint256 &hashBlock) |
| void | BatchWrite (CoinsViewCacheCursor &cursor, const uint256 &hashBlock) override |
| Do a bulk modification (multiple Coin changes + BestBlock change). More... | |
| std::unique_ptr< CCoinsViewCursor > | Cursor () const override |
| Get a cursor to iterate over the whole state. More... | |
| bool | HaveCoinInCache (const COutPoint &outpoint) const |
| Check if we have the given utxo already loaded in this cache. More... | |
| const Coin & | AccessCoin (const COutPoint &output) const |
| Return a reference to Coin in the cache, or coinEmpty if not found. More... | |
| void | AddCoin (const COutPoint &outpoint, Coin &&coin, bool possible_overwrite) |
| Add a coin. More... | |
| void | EmplaceCoinInternalDANGER (COutPoint &&outpoint, Coin &&coin) |
| Emplace a coin into cacheCoins without performing any checks, marking the emplaced coin as dirty. More... | |
| bool | SpendCoin (const COutPoint &outpoint, Coin *moveto=nullptr) |
| Spend a coin. More... | |
| void | Flush (bool reallocate_cache=true) |
| Push the modifications applied to this cache to its base and wipe local state. More... | |
| 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). More... | |
| void | Uncache (const COutPoint &outpoint) |
| Removes the UTXO with the given outpoint from the cache, if it is not modified. More... | |
| unsigned int | GetCacheSize () const |
| Size of the cache (in number of transaction outputs) More... | |
| size_t | GetDirtyCount () const noexcept |
| Number of dirty cache entries (transaction outputs) More... | |
| size_t | DynamicMemoryUsage () const |
| Calculate the size of the cache (in bytes) More... | |
| bool | HaveInputs (const CTransaction &tx) const |
| Check whether all prevouts of the transaction are present in the UTXO set represented by this view. More... | |
| void | ReallocateCache () |
| Force a reallocation of the cache map. More... | |
| void | SanityCheck () const |
| Run an internal sanity check on the cache data structure. */. More... | |
| ResetGuard | CreateResetGuard () noexcept |
Create a scoped guard that will call Reset() on this cache when it goes out of scope. More... | |
Public Member Functions inherited from CCoinsViewBacked | |
| CCoinsViewBacked (CCoinsView *viewIn) | |
| std::optional< Coin > | GetCoin (const COutPoint &outpoint) const override |
| Retrieve the Coin (unspent transaction output) for a given outpoint. More... | |
| std::optional< Coin > | PeekCoin (const COutPoint &outpoint) const override |
| Retrieve the Coin (unspent transaction output) for a given outpoint, without caching results. More... | |
| bool | HaveCoin (const COutPoint &outpoint) const override |
| Just check whether a given outpoint is unspent. More... | |
| uint256 | GetBestBlock () const override |
| Retrieve the block hash whose state this CCoinsView currently represents. More... | |
| std::vector< uint256 > | GetHeadBlocks () const override |
| Retrieve the range of blocks that may have been only partially written. More... | |
| void | SetBackend (CCoinsView &viewIn) |
| void | BatchWrite (CoinsViewCacheCursor &cursor, const uint256 &hashBlock) override |
| Do a bulk modification (multiple Coin changes + BestBlock change). More... | |
| std::unique_ptr< CCoinsViewCursor > | Cursor () const override |
| Get a cursor to iterate over the whole state. More... | |
| size_t | EstimateSize () const override |
| Estimate database size (0 if not implemented) More... | |
Public Member Functions inherited from CCoinsView | |
| virtual std::optional< Coin > | GetCoin (const COutPoint &outpoint) const |
| Retrieve the Coin (unspent transaction output) for a given outpoint. More... | |
| virtual std::optional< Coin > | PeekCoin (const COutPoint &outpoint) const |
| Retrieve the Coin (unspent transaction output) for a given outpoint, without caching results. More... | |
| virtual bool | HaveCoin (const COutPoint &outpoint) const |
| Just check whether a given outpoint is unspent. More... | |
| virtual uint256 | GetBestBlock () const |
| Retrieve the block hash whose state this CCoinsView currently represents. More... | |
| virtual std::vector< uint256 > | GetHeadBlocks () const |
| Retrieve the range of blocks that may have been only partially written. More... | |
| virtual void | BatchWrite (CoinsViewCacheCursor &cursor, const uint256 &hashBlock) |
| Do a bulk modification (multiple Coin changes + BestBlock change). More... | |
| virtual std::unique_ptr< CCoinsViewCursor > | Cursor () const |
| Get a cursor to iterate over the whole state. More... | |
| virtual | ~CCoinsView ()=default |
| As we use CCoinsViews polymorphically, have a virtual destructor. More... | |
| virtual size_t | EstimateSize () const |
| Estimate database size (0 if not implemented) More... | |
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. More... | |
| virtual std::optional< Coin > | FetchCoinFromBase (const COutPoint &outpoint) const |
Protected Attributes inherited from CCoinsViewCache | |
| uint256 | hashBlock |
| Make mutable so that we can "fill the cache" even from Get-methods declared as "const". More... | |
| 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.
Definition at line 540 of file coins.h.