14#include <validation.h>
20 :
nHeight(block_height), hashBlock(block_hash) {}
25 script_pub_key.size() ;
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());
56 ss <<
VARINT(it->first + 1);
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) {
93 const std::function<
void()> &interruption_point) {
94 std::unique_ptr<CCoinsViewCursor> pcursor(view->
Cursor());
100 std::map<uint32_t, Coin> outputs;
101 while (pcursor->Valid()) {
102 interruption_point();
105 if (pcursor->GetKey(key) && pcursor->GetValue(coin)) {
106 if (!outputs.empty() && key.GetTxId() != prevkey) {
111 prevkey = key.GetTxId();
112 outputs[key.GetN()] = std::move(coin);
115 return error(
"%s: unable to read value", __func__);
119 if (!outputs.empty()) {
131std::optional<CCoinsStats>
134 const std::function<
void()> &interruption_point) {
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.
virtual CCoinsViewCursor * Cursor() const
Get a cursor to iterate over the whole state.
virtual BlockHash GetBestBlock() const
Retrieve the block hash whose state this CCoinsView currently represents.
virtual size_t EstimateSize() const
Estimate database size (0 if not implemented)
Double ended buffer combining vector and stream-like interfaces.
uint32_t GetHeight() const
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.
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...
CBlockIndex * LookupBlockIndex(const BlockHash &hash) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
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)
#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