15#include <validation.h>
27 script_pub_key.
size() ;
52 for (
auto it = outputs.begin(); it != outputs.end(); ++it) {
53 if (it == outputs.begin()) {
55 ss <<
VARINT(it->second.nHeight * 2 + it->second.fCoinBase ? 1u : 0u);
58 ss <<
VARINT(it->first + 1);
59 ss << it->second.out.scriptPubKey;
62 if (it == std::prev(outputs.end())) {
68static void ApplyHash(std::nullptr_t,
const uint256& hash,
const std::map<uint32_t, Coin>& outputs) {}
72 for (
auto it = outputs.begin(); it != outputs.end(); ++it) {
74 Coin coin = it->second;
83 for (
auto it = outputs.begin(); it != outputs.end(); ++it) {
94 std::unique_ptr<CCoinsViewCursor> pcursor(view->
Cursor());
115 std::map<uint32_t, Coin> outputs;
116 while (pcursor->Valid()) {
117 interruption_point();
120 if (pcursor->GetKey(key) && pcursor->GetValue(coin)) {
121 if (!outputs.empty() && key.
hash != prevkey) {
127 outputs[key.
n] = std::move(coin);
130 return error(
"%s: unable to read value", __func__);
134 if (!outputs.empty()) {
150 return GetUTXOStats(view, blockman, stats, ss, interruption_point, pindex);
154 return GetUTXOStats(view, blockman, stats, muhash, interruption_point, pindex);
157 return GetUTXOStats(view, blockman, stats,
nullptr, interruption_point, pindex);
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate.
#define Assert(val)
Identity function.
Maintains a tree of blocks (stored in m_block_index) which is consulted to determine where the most-w...
CBlockIndex * LookupBlockIndex(const uint256 &hash) const EXCLUSIVE_LOCKS_REQUIRED(cs_main)
The block chain is a tree shaped structure starting with the genesis block at the root,...
uint256 GetBlockHash() const
Abstract view on the open txout dataset.
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.
virtual uint256 GetBestBlock() const
Retrieve the block hash whose state this CCoinsView currently represents.
Double ended buffer combining vector and stream-like interfaces.
A writer stream (for serialization) that computes a 256-bit hash.
uint256 GetHash()
Compute the double-SHA256 hash of all data written to this object.
An outpoint - a combination of a transaction hash and an index n into its vout.
Serialized script, used inside transaction inputs and outputs.
CTxOut out
unspent transaction output
uint32_t nHeight
at which height this containing transaction was included in the active block chain
unsigned int fCoinBase
whether containing transaction was a coinbase
A class representing MuHash sets.
void Finalize(uint256 &out) noexcept
MuHash3072 & Insert(Span< const unsigned char > in) noexcept
CDataStream TxOutSer(const COutPoint &outpoint, const Coin &coin)
uint64_t GetBogoSize(const CScript &script_pub_key)
static void ApplyStats(CCoinsStats &stats, const uint256 &hash, const std::map< uint32_t, Coin > &outputs)
static void PrepareHash(CHashWriter &ss, const CCoinsStats &stats)
static void FinalizeHash(CHashWriter &ss, CCoinsStats &stats)
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.
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 ...
std::unique_ptr< CoinStatsIndex > g_coin_stats_index
The global UTXO set hash object.
#define T(expected, seed, data)
#define VARINT_MODE(obj, mode)
constexpr auto MakeUCharSpan(V &&v) -> decltype(UCharSpanCast(MakeSpan(std::forward< V >(v))))
Like MakeSpan, but for (const) unsigned char member types only.
uint64_t nTransactionOutputs
bool index_used
Signals if the coinstatsindex was used to retrieve the statistics.
bool index_requested
Signals if the coinstatsindex should be used (when available).
uint64_t coins_count
The number of coins contained.
CoinStatsHashType m_hash_type
bool error(const char *fmt, const Args &... args)
static const int PROTOCOL_VERSION
network protocol versioning