12 #include <validation.h> 17 const std::map<uint32_t, Coin> &outputs) {
18 assert(!outputs.empty());
20 ss <<
VARINT(outputs.begin()->second.GetHeight() * 2 +
21 outputs.begin()->second.IsCoinBase());
23 for (
const auto &output : outputs) {
24 ss <<
VARINT(output.first + 1);
25 ss << output.second.GetTxOut().scriptPubKey;
33 output.second.GetTxOut().scriptPubKey.size() ;
40 const std::function<
void()> &interruption_point) {
42 std::unique_ptr<CCoinsViewCursor> pcursor(view->
Cursor());
46 stats.
hashBlock = pcursor->GetBestBlock();
53 std::map<uint32_t, Coin> outputs;
54 while (pcursor->Valid()) {
58 if (pcursor->GetKey(key) && pcursor->GetValue(coin)) {
59 if (!outputs.empty() && key.
GetTxId() != prevkey) {
64 outputs[key.
GetN()] = std::move(coin);
67 return error(
"%s: unable to read value", __func__);
71 if (!outputs.empty()) {
bool GetUTXOStats(CCoinsView *view, CCoinsStats &stats, const std::function< void()> &interruption_point)
Calculate statistics about the unspent transaction output set.
uint64_t nTransactionOutputs
virtual CCoinsViewCursor * Cursor() const
Get a cursor to iterate over the whole state.
const TxId & GetTxId() const
static constexpr Amount SATOSHI
#define VARINT_MODE(obj, mode)
Abstract view on the open txout dataset.
uint64_t coins_count
The number of coins contained.
RecursiveMutex cs_main
Global state.
An outpoint - a combination of a transaction hash and an index n into its vout.
static void ApplyStats(CCoinsStats &stats, CHashWriter &ss, const uint256 &hash, const std::map< uint32_t, Coin > &outputs)
virtual size_t EstimateSize() const
Estimate database size (0 if not implemented)
static const int PROTOCOL_VERSION
network protocol versioning
CBlockIndex * LookupBlockIndex(const BlockHash &hash)
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)