23 #include <validation.h> 38 hashBlock(block_hash) {}
48 script_pub_key.
size() ;
73 for (
auto it = outputs.begin(); it != outputs.end(); ++it) {
74 if (it == outputs.begin()) {
76 ss <<
VARINT(it->second.nHeight * 2 + it->second.fCoinBase ? 1u : 0u);
79 ss <<
VARINT(it->first + 1);
80 ss << it->second.out.scriptPubKey;
83 if (it == std::prev(outputs.end())) {
89 static void ApplyHash(std::nullptr_t,
const uint256& hash,
const std::map<uint32_t, Coin>& outputs) {}
93 for (
auto it = outputs.begin(); it != outputs.end(); ++it) {
95 Coin coin = it->second;
104 for (
auto it = outputs.begin(); it != outputs.end(); ++it) {
114 template <
typename T>
117 std::unique_ptr<CCoinsViewCursor> pcursor(view->
Cursor());
123 std::map<uint32_t, Coin> outputs;
124 while (pcursor->Valid()) {
125 interruption_point();
128 if (pcursor->GetKey(key) && pcursor->GetValue(coin)) {
129 if (!outputs.empty() && key.
hash != prevkey) {
135 outputs[key.
n] = std::move(coin);
138 return error(
"%s: unable to read value", __func__);
142 if (!outputs.empty()) {
159 bool success = [&]() ->
bool {
uint256 GetHash()
Compute the double-SHA256 hash of all data written to this object.
uint64_t GetBogoSize(const CScript &script_pub_key)
CDataStream TxOutSer(const COutPoint &outpoint, const Coin &coin)
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
static void ApplyHash(HashWriter &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 ...
static void PrepareHash(HashWriter &ss, const CCoinsStats &stats)
uint64_t coins_count
The number of coins contained.
Double ended buffer combining vector and stream-like interfaces.
static void ApplyStats(CCoinsStats &stats, const uint256 &hash, const std::map< uint32_t, Coin > &outputs)
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 ...
#define VARINT_MODE(obj, mode)
Abstract view on the open txout dataset.
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...
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)
#define WITH_LOCK(cs, code)
Run code while locking a mutex.
void Finalize(uint256 &out) noexcept
static void FinalizeHash(HashWriter &ss, CCoinsStats &stats)
static bool ComputeUTXOStats(CCoinsView *view, CCoinsStats &stats, T hash_obj, const std::function< void()> &interruption_point)
Calculate statistics about the unspent transaction output set.
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 const int PROTOCOL_VERSION
network protocol versioning
virtual uint256 GetBestBlock() const
Retrieve the block hash whose state this CCoinsView currently represents.
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate...
constexpr auto MakeUCharSpan(V &&v) -> decltype(UCharSpanCast(Span
Like the Span constructor, but for (const) unsigned char member types only.
A class representing MuHash sets.
virtual std::unique_ptr< CCoinsViewCursor > Cursor() const
Get a cursor to iterate over the whole state.
MuHash3072 & Insert(Span< const unsigned char > in) noexcept
uint64_t nTransactionOutputs
bool error(const char *fmt, const Args &... args)
#define Assert(val)
Identity function.