#include <coins.h>
CCoinsView that adds a memory cache for transactions to another CCoinsView
◆ CCoinsViewCache() [1/2]
CCoinsViewCache::CCoinsViewCache |
( |
CCoinsView * |
baseIn | ) |
|
◆ CCoinsViewCache() [2/2]
By deleting the copy constructor, we prevent accidentally using it when one intends to create a cache on top of a base cache.
◆ AccessCoin()
const Coin & CCoinsViewCache::AccessCoin |
( |
const COutPoint & |
output | ) |
const |
Return a reference to Coin in the cache, or a pruned one if not found. This is more efficient than GetCoin.
Generally, do not hold the reference returned for more than a short scope. While the current implementation allows for modifications to the contents of the cache while holding the reference, this behavior should not be relied on! To be safe, best to not hold the returned reference through any other calls to this cache.
◆ AddCoin()
void CCoinsViewCache::AddCoin |
( |
const COutPoint & |
outpoint, |
|
|
Coin && |
coin, |
|
|
bool |
potential_overwrite |
|
) |
| |
Add a coin. Set potential_overwrite to true if a non-pruned version may already exist.
◆ BatchWrite()
bool CCoinsViewCache::BatchWrite |
( |
CCoinsMap & |
mapCoins, |
|
|
const uint256 & |
hashBlock |
|
) |
| |
|
overridevirtual |
Do a bulk modification (multiple Coin changes + BestBlock change). The passed mapCoins can be modified.
Reimplemented from CCoinsViewBacked.
◆ Cursor()
Get a cursor to iterate over the whole state.
Reimplemented from CCoinsViewBacked.
◆ DynamicMemoryUsage()
size_t CCoinsViewCache::DynamicMemoryUsage |
( |
| ) |
const |
Calculate the size of the cache (in bytes)
◆ FetchCoin()
CCoinsMap::iterator CCoinsViewCache::FetchCoin |
( |
const COutPoint & |
outpoint | ) |
const |
|
private |
- Note
- this is marked const, but may actually append to
cacheCoins
, increasing memory usage.
◆ Flush()
bool CCoinsViewCache::Flush |
( |
| ) |
|
Push the modifications applied to this cache to its base. Failure to call this method before destruction will cause the changes to be forgotten. If false is returned, the state of this cache (and its backing view) will be undefined.
◆ GetBestBlock()
uint256 CCoinsViewCache::GetBestBlock |
( |
| ) |
const |
|
overridevirtual |
◆ GetCacheSize()
unsigned int CCoinsViewCache::GetCacheSize |
( |
| ) |
const |
Calculate the size of the cache (in number of transaction outputs)
◆ GetCoin()
bool CCoinsViewCache::GetCoin |
( |
const COutPoint & |
outpoint, |
|
|
Coin & |
coin |
|
) |
| const |
|
overridevirtual |
Retrieve the Coin (unspent transaction output) for a given outpoint. Returns true only when an unspent coin was found, which is returned in coin. When false is returned, coin's value is unspecified.
Reimplemented from CCoinsViewBacked.
◆ GetValueIn()
Amount of bitcoins coming in to a transaction Note that lightweight clients may not know anything besides the hash of previous transactions, so may not be able to calculate this.
- Parameters
-
[in] | tx | transaction for which we are checking input total |
- Returns
- Sum of value of all inputs (scriptSigs)
◆ HaveCoin()
bool CCoinsViewCache::HaveCoin |
( |
const COutPoint & |
outpoint | ) |
const |
|
overridevirtual |
Just check whether a given outpoint is unspent.
Reimplemented from CCoinsViewBacked.
◆ HaveCoinInCache()
bool CCoinsViewCache::HaveCoinInCache |
( |
const COutPoint & |
outpoint | ) |
const |
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.
◆ HaveInputs()
bool CCoinsViewCache::HaveInputs |
( |
const CTransaction & |
tx | ) |
const |
Check whether all prevouts of the transaction are present in the UTXO set represented by this view.
◆ SetBestBlock()
void CCoinsViewCache::SetBestBlock |
( |
const uint256 & |
hashBlock | ) |
|
◆ SpendCoin()
bool CCoinsViewCache::SpendCoin |
( |
const COutPoint & |
outpoint, |
|
|
Coin * |
moveto = nullptr |
|
) |
| |
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.
◆ Uncache()
void CCoinsViewCache::Uncache |
( |
const COutPoint & |
outpoint | ) |
|
Removes the UTXO with the given outpoint from the cache, if it is not modified.
◆ cacheCoins
◆ cachedCoinsUsage
size_t CCoinsViewCache::cachedCoinsUsage |
|
mutableprotected |
◆ hashBlock
Make mutable so that we can "fill the cache" even from Get-methods declared as "const".
The documentation for this class was generated from the following files: