13 #include <validation.h> 31 ss <<
VARINT(outputs.begin()->second.nHeight * 2 + outputs.begin()->second.fCoinBase ? 1u : 0u);
33 for (
const auto& output : outputs) {
34 ss <<
VARINT(output.first + 1);
35 ss << output.second.out.scriptPubKey;
48 for (
const auto& output : outputs) {
60 std::unique_ptr<CCoinsViewCursor> pcursor(view->
Cursor());
63 stats.
hashBlock = pcursor->GetBestBlock();
72 std::map<uint32_t, Coin> outputs;
73 while (pcursor->Valid()) {
77 if (pcursor->GetKey(key) && pcursor->GetValue(coin)) {
78 if (!outputs.empty() && key.
hash != prevkey) {
83 outputs[key.
n] = std::move(coin);
86 return error(
"%s: unable to read value", __func__);
90 if (!outputs.empty()) {
105 return GetUTXOStats(view, stats, ss, interruption_point);
108 return GetUTXOStats(view, stats,
nullptr, interruption_point);
uint64_t nTransactionOutputs
static uint64_t GetBogoSize(const CScript &scriptPubKey)
virtual CCoinsViewCursor * Cursor() const
Get a cursor to iterate over the whole state.
static void FinalizeHash(CHashWriter &ss, CCoinsStats &stats)
#define VARINT_MODE(obj, mode)
Abstract view on the open txout dataset.
uint64_t coins_count
The number of coins contained.
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate...
An outpoint - a combination of a transaction hash and an index n into its vout.
static bool GetUTXOStats(CCoinsView *view, CCoinsStats &stats, T hash_obj, const std::function< void()> &interruption_point)
Calculate statistics about the unspent transaction output set.
uint256 GetHash()
Compute the double-SHA256 hash of all data written to this object.
CBlockIndex * LookupBlockIndex(const uint256 &hash)
static void ApplyStats(CCoinsStats &stats, CHashWriter &ss, const uint256 &hash, const std::map< uint32_t, Coin > &outputs)
static void PrepareHash(CHashWriter &ss, const CCoinsStats &stats)
virtual size_t EstimateSize() const
Estimate database size (0 if not implemented)
Serialized script, used inside transaction inputs and outputs.
static const int PROTOCOL_VERSION
network protocol versioning
A writer stream (for serialization) that computes a 256-bit hash.
int nHeight
height of the entry in the chain. The genesis block has height 0
bool error(const char *fmt, const Args &... args)