14#include <validation.h>
20 :
nHeight(block_height), hashBlock(block_hash) {}
49 const std::map<uint32_t, Coin> &outputs) {
50 for (
auto it = outputs.begin(); it != outputs.end(); ++it) {
51 if (it == outputs.begin()) {
53 ss <<
VARINT(it->second.GetHeight() * 2 + it->second.IsCoinBase());
57 ss << it->second.GetTxOut().scriptPubKey;
61 if (it == std::prev(outputs.end())) {
68 const std::map<uint32_t, Coin> &outputs) {}
71 const std::map<uint32_t, Coin> &outputs) {
72 for (
auto it = outputs.begin(); it != outputs.end(); ++it) {
73 COutPoint outpoint = COutPoint(txid, it->first);
74 Coin coin = it->second;
80 const std::map<uint32_t, Coin> &outputs) {
83 for (
auto it = outputs.begin(); it != outputs.end(); ++it) {
94 std::unique_ptr<CCoinsViewCursor> pcursor(
view->Cursor());
100 std::map<uint32_t, Coin> outputs;
101 while (pcursor->Valid()) {
105 if (pcursor->GetKey(key) && pcursor->GetValue(coin)) {
106 if (!outputs.empty() && key.GetTxId() !=
prevkey) {
112 outputs[key.GetN()] = std::move(coin);
119 if (!outputs.empty()) {
131std::optional<CCoinsStats>
139 bool success = [&]() ->
bool {
static constexpr Amount SATOSHI
#define Assert(val)
Identity function.
The block chain is a tree shaped structure starting with the genesis block at the root,...
BlockHash GetBlockHash() const
Abstract view on the open txout dataset.
Double ended buffer combining vector and stream-like interfaces.
uint32_t GetHeight() const
A writer stream (for serialization) that computes a 256-bit hash.
A class representing MuHash sets.
void Finalize(uint256 &out) noexcept
MuHash3072 & Insert(Span< const uint8_t > in) noexcept
Maintains a tree of blocks (stored in m_block_index) which is consulted to determine where the most-w...
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate.
bool error(const char *fmt, const Args &...args)
static void FinalizeHash(HashWriter &ss, CCoinsStats &stats)
static void ApplyStats(CCoinsStats &stats, const TxId &txid, const std::map< uint32_t, Coin > &outputs)
CDataStream TxOutSer(const COutPoint &outpoint, const Coin &coin)
static void ApplyHash(HashWriter &ss, const TxId &txid, const std::map< uint32_t, Coin > &outputs)
Warning: be very careful when changing this! assumeutxo and UTXO snapshot validation commitments are ...
static bool ComputeUTXOStats(CCoinsView *view, CCoinsStats &stats, T hash_obj, const std::function< void()> &interruption_point)
Calculate statistics about the unspent transaction output set.
static void PrepareHash(HashWriter &ss, const CCoinsStats &stats)
uint64_t GetBogoSize(const CScript &script_pub_key)
T GetRand(T nMax=std::numeric_limits< T >::max()) noexcept
Generate a uniform random integer of type T in the range [0..nMax) nMax defaults to std::numeric_limi...
#define VARINT_MODE(obj, mode)
constexpr auto MakeUCharSpan(V &&v) -> decltype(UCharSpanCast(Span{std::forward< V >(v)}))
Like the Span constructor, but for (const) uint8_t member types only.
A BlockHash is a unqiue identifier for a block.
A TxId is the identifier of a transaction.
uint64_t coins_count
The number of coins contained.
uint64_t nTransactionOutputs
#define WITH_LOCK(cs, code)
Run code while locking a mutex.
static const int PROTOCOL_VERSION
network protocol versioning