21 #include <validation.h> 33 hashBlock(block_hash) {}
43 script_pub_key.
size() ;
88 static void ApplyHash(T& hash_obj,
const Txid& hash,
const std::map<uint32_t, Coin>& outputs)
90 for (
auto it = outputs.begin(); it != outputs.end(); ++it) {
92 Coin coin = it->second;
101 for (
auto it = outputs.begin(); it != outputs.end(); ++it) {
111 template <
typename T>
117 std::map<uint32_t, Coin> outputs;
118 while (pcursor->Valid()) {
119 if (interruption_point) 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 LogError(
"%s: unable to read value\n", __func__);
137 if (!outputs.empty()) {
151 std::unique_ptr<CCoinsViewCursor> pcursor;
160 bool success = [&]() ->
bool {
164 return ComputeUTXOStats(view, stats, ss, interruption_point, std::move(pcursor));
168 return ComputeUTXOStats(view, stats, muhash, interruption_point, std::move(pcursor));
171 return ComputeUTXOStats(view, stats,
nullptr, interruption_point, std::move(pcursor));
uint256 GetHash()
Compute the double-SHA256 hash of all data written to this object.
uint64_t GetBogoSize(const CScript &script_pub_key)
constexpr auto MakeUCharSpan(const V &v) -> decltype(UCharSpanCast(std::span
Like the std::span constructor, but for (const) unsigned char member types only.
static void ApplyStats(CCoinsStats &stats, const std::map< uint32_t, Coin > &outputs)
CTxOut out
unspent transaction output
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
uint64_t coins_count
The number of coins contained.
void RemoveCoinHash(MuHash3072 &muhash, const COutPoint &outpoint, const Coin &coin)
static void TxOutSer(T &ss, const COutPoint &outpoint, const Coin &coin)
std::optional< T > CheckedAdd(const T i, const T j) noexcept
uint256 GetBlockHash() const
uint32_t nHeight
at which height this containing transaction was included in the active block chain ...
Abstract view on the open txout dataset.
Double ended buffer combining vector and stream-like interfaces.
A writer stream (for serialization) that computes a 256-bit hash.
Maintains a tree of blocks (stored in m_block_index) which is consulted to determine where the most-w...
MuHash3072 & Insert(std::span< const unsigned char > in) noexcept
An outpoint - a combination of a transaction hash and an index n into its vout.
CBlockIndex * LookupBlockIndex(const uint256 &hash) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
void Finalize(uint256 &out) noexcept
static void ApplyHash(T &hash_obj, const Txid &hash, const std::map< uint32_t, Coin > &outputs)
Warning: be very careful when changing this! assumeutxo and UTXO snapshot validation commitments are ...
static void FinalizeHash(HashWriter &ss, CCoinsStats &stats)
virtual size_t EstimateSize() const
Estimate database size (0 if not implemented)
The block chain is a tree shaped structure starting with the genesis block at the root...
Serialized script, used inside transaction inputs and outputs.
static bool ComputeUTXOStats(CCoinsView *view, CCoinsStats &stats, T hash_obj, const std::function< void()> &interruption_point, std::unique_ptr< CCoinsViewCursor > pcursor)
Calculate statistics about the unspent transaction output set.
A class representing MuHash sets.
virtual std::unique_ptr< CCoinsViewCursor > Cursor() const
Get a cursor to iterate over the whole state.
MuHash3072 & Remove(std::span< const unsigned char > in) noexcept
uint64_t nTransactionOutputs
static void ApplyCoinHash(HashWriter &ss, const COutPoint &outpoint, const Coin &coin)
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate...
#define Assert(val)
Identity function.