Bitcoin ABC  0.29.2
P2P Digital Currency
coinstats.h
Go to the documentation of this file.
1 // Copyright (c) 2010 Satoshi Nakamoto
2 // Copyright (c) 2009-2019 The Bitcoin Core developers
3 // Distributed under the MIT software license, see the accompanying
4 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
5 
6 #ifndef BITCOIN_NODE_COINSTATS_H
7 #define BITCOIN_NODE_COINSTATS_H
8 
9 #include <chain.h>
10 #include <coins.h>
11 #include <consensus/amount.h>
12 #include <primitives/blockhash.h>
13 #include <streams.h>
14 #include <uint256.h>
15 
16 #include <cstdint>
17 #include <functional>
18 #include <optional>
19 
20 class CCoinsView;
21 namespace node {
22 class BlockManager;
23 } // namespace node
24 
25 namespace node {
26 enum class CoinStatsHashType {
28  MUHASH,
29  NONE,
30 };
31 
32 struct CCoinsStats {
33  int nHeight{0};
35  uint64_t nTransactions{0};
36  uint64_t nTransactionOutputs{0};
37  uint64_t nBogoSize{0};
39  uint64_t nDiskSize{0};
41 
43  uint64_t coins_count{0};
44 
46  bool index_used{false};
47 
48  // Following values are only available from coinstats index
49 
74 
75  CCoinsStats() = default;
76  CCoinsStats(int block_height, const BlockHash &block_hash);
77 };
78 
85 std::optional<CCoinsStats>
87  CoinStatsHashType hash_type,
88  const std::function<void()> &interruption_point = {},
89  const CBlockIndex *pindex = nullptr, bool index_requested = true);
90 
91 uint64_t GetBogoSize(const CScript &script_pub_key);
92 
93 CDataStream TxOutSer(const COutPoint &outpoint, const Coin &coin);
94 
95 std::optional<CCoinsStats>
97  BlockManager &blockman,
98  const std::function<void()> &interruption_point = {});
99 } // namespace node
100 
101 #endif // BITCOIN_NODE_COINSTATS_H
The block chain is a tree shaped structure starting with the genesis block at the root,...
Definition: blockindex.h:26
Abstract view on the open txout dataset.
Definition: coins.h:147
Double ended buffer combining vector and stream-like interfaces.
Definition: streams.h:177
An outpoint - a combination of a transaction hash and an index n into its vout.
Definition: transaction.h:20
Serialized script, used inside transaction inputs and outputs.
Definition: script.h:431
A UTXO entry.
Definition: coins.h:27
Maintains a tree of blocks (stored in m_block_index) which is consulted to determine where the most-w...
Definition: blockstorage.h:67
256-bit opaque blob.
Definition: uint256.h:129
Definition: init.h:28
CoinStatsHashType
Definition: coinstats.h:26
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:95
CDataStream TxOutSer(const COutPoint &outpoint, const Coin &coin)
Definition: coinstats.cpp:31
uint64_t GetBogoSize(const CScript &script_pub_key)
Definition: coinstats.cpp:25
std::optional< CCoinsStats > GetUTXOStats(CCoinsView *view, BlockManager &blockman, CoinStatsHashType hash_type, const std::function< void()> &interruption_point, const CBlockIndex *pindex, bool index_requested)
Calculate statistics about the unspent transaction output set.
Definition: coinstats.cpp:186
Definition: amount.h:19
static constexpr Amount zero() noexcept
Definition: amount.h:32
A BlockHash is a unqiue identifier for a block.
Definition: blockhash.h:13
Amount total_coinbase_amount
Total cumulative amount of coinbase outputs up to and including this block.
Definition: coinstats.h:63
Amount total_unspendables_genesis_block
The unspendable coinbase amount from the genesis block.
Definition: coinstats.h:65
Amount total_unspendables_unclaimed_rewards
Total cumulative amount of coins lost due to unclaimed miner rewards up to and including this block.
Definition: coinstats.h:73
Amount nTotalAmount
Definition: coinstats.h:40
uint64_t nBogoSize
Definition: coinstats.h:37
uint64_t nDiskSize
Definition: coinstats.h:39
CCoinsStats()=default
Amount total_prevout_spent_amount
Total cumulative amount of prevouts spent up to and including this block.
Definition: coinstats.h:57
bool index_used
Signals if the coinstatsindex was used to retrieve the statistics.
Definition: coinstats.h:46
Amount total_unspendable_amount
Total cumulative amount of unspendable coins up to and including this block.
Definition: coinstats.h:55
Amount total_new_outputs_ex_coinbase_amount
Total cumulative amount of outputs created up to and including this block.
Definition: coinstats.h:60
BlockHash hashBlock
Definition: coinstats.h:34
Amount total_unspendables_bip30
The two unspendable coinbase outputs total amount caused by BIP30.
Definition: coinstats.h:67
uint64_t nTransactions
Definition: coinstats.h:35
uint64_t nTransactionOutputs
Definition: coinstats.h:36
uint256 hashSerialized
Definition: coinstats.h:38
Amount total_unspendables_scripts
Total cumulative amount of outputs sent to unspendable scripts (OP_RETURN for example) up to and incl...
Definition: coinstats.h:70
Amount total_subsidy
Total cumulative amount of block subsidies up to and including this block.
Definition: coinstats.h:52
uint64_t coins_count
The number of coins contained.
Definition: coinstats.h:43