Bitcoin Core 30.99.0
P2P Digital Currency
coinstats.h
Go to the documentation of this file.
1// Copyright (c) 2022 The Bitcoin Core developers
2// Distributed under the MIT software license, see the accompanying
3// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
5#ifndef BITCOIN_KERNEL_COINSTATS_H
6#define BITCOIN_KERNEL_COINSTATS_H
7
8#include <arith_uint256.h>
9#include <consensus/amount.h>
10#include <crypto/muhash.h>
11#include <streams.h>
12#include <uint256.h>
13
14#include <cstdint>
15#include <functional>
16#include <optional>
17
18class CCoinsView;
19class Coin;
20class COutPoint;
21class CScript;
22namespace node {
23class BlockManager;
24} // namespace node
25
26namespace kernel {
29 MUHASH,
30 NONE,
31};
32
34 int nHeight{0};
36 uint64_t nTransactions{0};
38 uint64_t nBogoSize{0};
40 uint64_t nDiskSize{0};
42 std::optional<CAmount> total_amount{0};
43
45 uint64_t coins_count{0};
46
48 bool index_used{false};
49
50 // Following values are only available from coinstats index
51
62
63 // Despite containing amounts the following values use a uint256 type to prevent overflowing
64
71
72 CCoinsStats() = default;
73 CCoinsStats(int block_height, const uint256& block_hash);
74};
75
76uint64_t GetBogoSize(const CScript& script_pub_key);
77
78void ApplyCoinHash(MuHash3072& muhash, const COutPoint& outpoint, const Coin& coin);
79void RemoveCoinHash(MuHash3072& muhash, const COutPoint& outpoint, const Coin& coin);
80
81std::optional<CCoinsStats> ComputeUTXOStats(CoinStatsHashType hash_type, CCoinsView* view, node::BlockManager& blockman, const std::function<void()>& interruption_point = {});
82} // namespace kernel
83
84#endif // BITCOIN_KERNEL_COINSTATS_H
int64_t CAmount
Amount in satoshis (Can be negative)
Definition: amount.h:12
Abstract view on the open txout dataset.
Definition: coins.h:310
An outpoint - a combination of a transaction hash and an index n into its vout.
Definition: transaction.h:29
Serialized script, used inside transaction inputs and outputs.
Definition: script.h:413
A UTXO entry.
Definition: coins.h:33
A class representing MuHash sets.
Definition: muhash.h:100
256-bit unsigned big integer.
Maintains a tree of blocks (stored in m_block_index) which is consulted to determine where the most-w...
Definition: blockstorage.h:139
256-bit opaque blob.
Definition: uint256.h:196
void RemoveCoinHash(MuHash3072 &muhash, const COutPoint &outpoint, const Coin &coin)
Definition: coinstats.cpp:70
static bool ComputeUTXOStats(CCoinsView *view, CCoinsStats &stats, T hash_obj, const std::function< void()> &interruption_point)
Calculate statistics about the unspent transaction output set.
Definition: coinstats.cpp:116
CoinStatsHashType
Definition: coinstats.h:27
static void ApplyCoinHash(HashWriter &ss, const COutPoint &outpoint, const Coin &coin)
Definition: coinstats.cpp:58
uint64_t GetBogoSize(const CScript &script_pub_key)
Definition: coinstats.cpp:40
Definition: messages.h:20
arith_uint256 total_prevout_spent_amount
Total cumulative amount of prevouts spent up to and including this block.
Definition: coinstats.h:66
std::optional< CAmount > total_amount
The total amount, or nullopt if an overflow occurred calculating it.
Definition: coinstats.h:42
uint64_t nDiskSize
Definition: coinstats.h:40
CAmount total_unspendables_scripts
Total cumulative amount of outputs sent to unspendable scripts (OP_RETURN for example) up to and incl...
Definition: coinstats.h:59
uint64_t coins_count
The number of coins contained.
Definition: coinstats.h:45
uint64_t nTransactions
Definition: coinstats.h:36
arith_uint256 total_coinbase_amount
Total cumulative amount of coinbase outputs up to and including this block.
Definition: coinstats.h:70
uint64_t nTransactionOutputs
Definition: coinstats.h:37
uint64_t nBogoSize
Definition: coinstats.h:38
bool index_used
Signals if the coinstatsindex was used to retrieve the statistics.
Definition: coinstats.h:48
CAmount total_unspendables_bip30
The two unspendable coinbase outputs total amount caused by BIP30.
Definition: coinstats.h:57
CAmount total_unspendables_genesis_block
The unspendable coinbase amount from the genesis block.
Definition: coinstats.h:55
uint256 hashSerialized
Definition: coinstats.h:39
arith_uint256 total_new_outputs_ex_coinbase_amount
Total cumulative amount of outputs created up to and including this block.
Definition: coinstats.h:68
CAmount total_unspendables_unclaimed_rewards
Total cumulative amount of coins lost due to unclaimed miner rewards up to and including this block.
Definition: coinstats.h:61
CAmount total_subsidy
Total cumulative amount of block subsidies up to and including this block.
Definition: coinstats.h:53