Bitcoin Core 31.0.0
P2P Digital Currency
Loading...
Searching...
No Matches
coins.h File Reference
#include <attributes.h>
#include <compressor.h>
#include <core_memusage.h>
#include <memusage.h>
#include <primitives/transaction.h>
#include <serialize.h>
#include <support/allocators/pool.h>
#include <uint256.h>
#include <util/check.h>
#include <util/overflow.h>
#include <util/hasher.h>
#include <cassert>
#include <cstdint>
#include <functional>
#include <unordered_map>
Include dependency graph for coins.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  Coin
 A UTXO entry. More...
struct  CCoinsCacheEntry
 A Coin in one level of the coins database caching hierarchy. More...
class  CCoinsViewCursor
 Cursor for iterating over CoinsView state. More...
struct  CoinsViewCacheCursor
 Cursor for iterating over the linked list of flagged entries in CCoinsViewCache. More...
class  CCoinsView
 Abstract view on the open txout dataset. More...
class  CCoinsViewBacked
 CCoinsView backed by another CCoinsView. More...
class  CCoinsViewCache
 CCoinsView that adds a memory cache for transactions to another CCoinsView. More...
class  CCoinsViewCache::ResetGuard
class  CoinsViewOverlay
 CCoinsViewCache overlay that avoids populating/mutating parent cache layers on cache misses. More...
class  CCoinsViewErrorCatcher
 This is a minimally invasive approach to shutdown on LevelDB read errors from the chainstate, while keeping user interface out of the common library, which is shared between bitcoind, and bitcoin-qt and non-server tools. More...

Typedefs

using CoinsCachePair = std::pair<const COutPoint, CCoinsCacheEntry>
using CCoinsMap
 PoolAllocator's MAX_BLOCK_SIZE_BYTES parameter here uses sizeof the data, and adds the size of 4 pointers.
using CCoinsMapMemoryResource = CCoinsMap::allocator_type::ResourceType

Functions

void AddCoins (CCoinsViewCache &cache, const CTransaction &tx, int nHeight, bool check=false)
const CoinAccessByTxid (const CCoinsViewCache &cache, const Txid &txid)

Typedef Documentation

◆ CCoinsMap

using CCoinsMap
Initial value:
std::unordered_map<COutPoint,
std::equal_to<COutPoint>,
sizeof(CoinsCachePair) + sizeof(void*) * 4>>
An outpoint - a combination of a transaction hash and an index n into its vout.
Definition transaction.h:29
Forwards all allocations/deallocations to the PoolResource.
Definition pool.h:290
std::pair< const COutPoint, CCoinsCacheEntry > CoinsCachePair
Definition coins.h:93
A Coin in one level of the coins database caching hierarchy.
Definition coins.h:110

PoolAllocator's MAX_BLOCK_SIZE_BYTES parameter here uses sizeof the data, and adds the size of 4 pointers.

We do not know the exact node size used in the std::unordered_node implementation because it is implementation defined. Most implementations have an overhead of 1 or 2 pointers, so nodes can be connected in a linked list, and in some cases the hash value is stored as well. Using an additional sizeof(void*)*4 for MAX_BLOCK_SIZE_BYTES should thus be sufficient so that all implementations can allocate the nodes from the PoolAllocator.

Definition at line 219 of file coins.h.

◆ CCoinsMapMemoryResource

using CCoinsMapMemoryResource = CCoinsMap::allocator_type::ResourceType

Definition at line 226 of file coins.h.

◆ CoinsCachePair

using CoinsCachePair = std::pair<const COutPoint, CCoinsCacheEntry>

Definition at line 93 of file coins.h.

Function Documentation

◆ AccessByTxid()

const Coin & AccessByTxid ( const CCoinsViewCache & cache,
const Txid & txid )

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.

Definition at line 386 of file coins.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ AddCoins()

void AddCoins ( CCoinsViewCache & cache,
const CTransaction & tx,
int nHeight,
bool check = false )

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.

Definition at line 142 of file coins.cpp.

Here is the call graph for this function:
Here is the caller graph for this function: