 |
Bitcoin Core
22.99.0
P2P Digital Currency
|
Go to the documentation of this file.
16 #include <validation.h>
29 script_pub_key.
size() ;
54 for (
auto it = outputs.begin(); it != outputs.end(); ++it) {
55 if (it == outputs.begin()) {
57 ss <<
VARINT(it->second.nHeight * 2 + it->second.fCoinBase ? 1u : 0u);
60 ss <<
VARINT(it->first + 1);
61 ss << it->second.out.scriptPubKey;
64 if (it == std::prev(outputs.end())) {
70 static void ApplyHash(std::nullptr_t,
const uint256& hash,
const std::map<uint32_t, Coin>& outputs) {}
74 for (
auto it = outputs.begin(); it != outputs.end(); ++it) {
76 Coin coin = it->second;
85 for (
auto it = outputs.begin(); it != outputs.end(); ++it) {
98 std::unique_ptr<CCoinsViewCursor> pcursor(view->
Cursor());
117 std::map<uint32_t, Coin> outputs;
118 while (pcursor->Valid()) {
119 interruption_point();
122 if (pcursor->GetKey(key) && pcursor->GetValue(coin)) {
123 if (!outputs.empty() && key.
hash != prevkey) {
129 outputs[key.
n] = std::move(coin);
132 return error(
"%s: unable to read value", __func__);
136 if (!outputs.empty()) {
152 return GetUTXOStats(view, blockman, stats, ss, interruption_point, pindex);
156 return GetUTXOStats(view, blockman, stats, muhash, interruption_point, pindex);
159 return GetUTXOStats(view, blockman, stats,
nullptr, interruption_point, pindex);
static bool GetUTXOStats(CCoinsView *view, BlockManager &blockman, CCoinsStats &stats, T hash_obj, const std::function< void()> &interruption_point, const CBlockIndex *pindex)
Calculate statistics about the unspent transaction output set.
constexpr auto MakeUCharSpan(V &&v) -> decltype(UCharSpanCast(Span
Like the Span constructor, but for (const) unsigned char member types only.
CBlockIndex * LookupBlockIndex(const uint256 &hash) const EXCLUSIVE_LOCKS_REQUIRED(cs_main)
static void PrepareHash(CHashWriter &ss, const CCoinsStats &stats)
bool index_requested
Signals if the coinstatsindex should be used (when available).
uint64_t nTransactionOutputs
#define VARINT_MODE(obj, mode)
MuHash3072 & Insert(Span< const unsigned char > in) noexcept
std::optional< CAmount > total_amount
The total amount, or nullopt if an overflow occurred calculating it.
unsigned int fCoinBase
whether containing transaction was a coinbase
#define Assert(val)
Identity function.
uint64_t coins_count
The number of coins contained.
std::unique_ptr< CoinStatsIndex > g_coin_stats_index
The global UTXO set hash object.
CDataStream TxOutSer(const COutPoint &outpoint, const Coin &coin)
static void FinalizeHash(CHashWriter &ss, CCoinsStats &stats)
Abstract view on the open txout dataset.
CTxOut out
unspent transaction output
Maintains a tree of blocks (stored in m_block_index) which is consulted to determine where the most-w...
uint32_t nHeight
at which height this containing transaction was included in the active block chain
std::optional< T > CheckedAdd(const T i, const T j) noexcept
void Finalize(uint256 &out) noexcept
Serialized script, used inside transaction inputs and outputs.
uint256 GetBlockHash() const
virtual size_t EstimateSize() const
Estimate database size (0 if not implemented)
virtual std::unique_ptr< CCoinsViewCursor > Cursor() const
Get a cursor to iterate over the whole state.
const CoinStatsHashType m_hash_type
Which hash type to use.
A writer stream (for serialization) that computes a 256-bit hash.
uint64_t GetBogoSize(const CScript &script_pub_key)
Double ended buffer combining vector and stream-like interfaces.
An outpoint - a combination of a transaction hash and an index n into its vout.
bool error(const char *fmt, const Args &... args)
static void ApplyHash(CHashWriter &ss, const uint256 &hash, const std::map< uint32_t, Coin > &outputs)
Warning: be very careful when changing this! assumeutxo and UTXO snapshot validation commitments are ...
uint256 GetHash()
Compute the double-SHA256 hash of all data written to this object.
static void ApplyStats(CCoinsStats &stats, const uint256 &hash, const std::map< uint32_t, Coin > &outputs)
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate.
The block chain is a tree shaped structure starting with the genesis block at the root,...
virtual uint256 GetBestBlock() const
Retrieve the block hash whose state this CCoinsView currently represents.
bool index_used
Signals if the coinstatsindex was used to retrieve the statistics.
A class representing MuHash sets.
static const int PROTOCOL_VERSION
network protocol versioning