CCoinsView that adds a memory cache for transactions to another CCoinsView
Synopsis
Declared in <coins.h>
class CCoinsViewCache
: public CCoinsViewBacked
Base Classes
Name |
Description |
CCoinsView backed by another CCoinsView |
Types
Name |
Description |
Scope guard that calls Reset() on its cache when it goes out of scope. |
Member Functions
Name |
Description |
|
Constructors |
Return a reference to Coin in the cache, or coinEmpty if not found. This is more efficient than GetCoin. |
|
Add a coin. Set possible_overwrite to true if an unspent version may already exist in the cache. |
|
|
Write flagged coins from a cursor into this cache and update the best block. |
Create a scoped guard that will call |
|
Calculate the size of the cache (in bytes) |
|
Emplace a coin into cacheCoins without performing any checks, marking the emplaced coin as dirty. |
|
|
Forward the size estimate to the backing view. |
|
Push the modifications applied to this cache to its base and wipe local state. Failure to call this method or Sync() before destruction will cause the changes to be forgotten. If reallocate_cache is false, the cache will retain the same memory footprint after flushing and should be destroyed to deallocate. |
|
Retrieve the best block hash this cache represents. |
Size of the cache (in number of transaction outputs) |
|
|
Retrieve a coin, populating this cache on a hit. |
Number of dirty cache entries (transaction outputs) |
|
|
Forward the head‐blocks query to the backing view. |
|
Check whether an outpoint is unspent, possibly populating this cache. |
Check if we have the given utxo already loaded in this cache. The semantics are the same as HaveCoin(), but no calls to the backing CCoinsView are made. |
|
Check whether all prevouts of the transaction are present in the UTXO set represented by this view |
|
|
Retrieve a coin without populating this cache. |
Run an internal sanity check on the cache data structure. */ |
|
Replace the backing view. |
|
Set the best block hash this cache represents. |
|
Spend a coin. Pass moveto in order to get the deleted data. If no unspent output exists for the passed outpoint, this call has no effect. |
|
Push the modifications applied to this cache to its base while retaining the contents of this cache (except for spent coins, which we erase). Failure to call this method or Flush() before destruction will cause the changes to be forgotten. |
|
Removes the UTXO with the given outpoint from the cache, if it is not modified. |
Protected Member Functions
Name |
Description |
|
Fetch the coin from base. Used for cache misses in FetchCoin. |
|
Discard all modifications made to this cache without flushing to the base view. This can be used to efficiently reuse a cache instance across multiple operations. |
Protected Data Members
Name |
Description |
The underlying view that all calls are forwarded to. |
|
The map of cached coins, keyed by outpoint. |
|
Cached dynamic memory usage for the inner Coin objects. |
|
Make mutable so that we can "fill the cache" even from Get‐methods declared as "const". |
|
Memory resource that backs the pool allocator used by cacheCoins. |
|
Running count of dirty Coin cache entries. |
|
The starting sentinel of the flagged entry circular doubly linked list. |
Non-Member Functions
Name |
Description |
Utility function to find any unspent output with a given txid. This function can be quite expensive because in the event of a transaction which is not found in the cache, it can cause up to MAX_OUTPUTS_PER_BLOCK lookups to database, so it should be used with care. |
|
Utility function to add all of a transaction's outputs to a cache. When check is false, this assumes that overwrites are only possible for coinbase transactions. When check is true, the underlying view may be queried to determine whether an addition is an overwrite. |
Derived Classes
Name |
Description |
CCoinsViewCache subclass that asynchronously fetches most block input prevouts in parallel during ConnectBlock without mutating the base cache. |
Created with MrDocs