Bitcoin ABC  0.26.3
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 
19 class BlockManager;
20 class CCoinsView;
21 
22 enum class CoinStatsHashType {
24  MUHASH,
25  NONE,
26 };
27 
28 struct CCoinsStats {
30  int nHeight{0};
32  uint64_t nTransactions{0};
33  uint64_t nTransactionOutputs{0};
34  uint64_t nBogoSize{0};
36  uint64_t nDiskSize{0};
38 
40  uint64_t coins_count{0};
41 
43  bool index_requested{true};
45  bool index_used{false};
46 
47  // Following values are only available from coinstats index
57 
58  CCoinsStats(CoinStatsHashType hash_type) : m_hash_type(hash_type) {}
59 };
60 
62 bool GetUTXOStats(CCoinsView *view, BlockManager &blockman, CCoinsStats &stats,
63  const std::function<void()> &interruption_point = {},
64  const CBlockIndex *pindex = nullptr);
65 
66 uint64_t GetBogoSize(const CScript &script_pub_key);
67 
68 CDataStream TxOutSer(const COutPoint &outpoint, const Coin &coin);
69 
70 #endif // BITCOIN_NODE_COINSTATS_H
Maintains a tree of blocks (stored in m_block_index) which is consulted to determine where the most-w...
Definition: blockstorage.h:61
The block chain is a tree shaped structure starting with the genesis block at the root,...
Definition: blockindex.h:23
Abstract view on the open txout dataset.
Definition: coins.h:147
Double ended buffer combining vector and stream-like interfaces.
Definition: streams.h:197
An outpoint - a combination of a transaction hash and an index n into its vout.
Definition: transaction.h:22
Serialized script, used inside transaction inputs and outputs.
Definition: script.h:431
A UTXO entry.
Definition: coins.h:27
256-bit opaque blob.
Definition: uint256.h:127
CDataStream TxOutSer(const COutPoint &outpoint, const Coin &coin)
Definition: coinstats.cpp:26
uint64_t GetBogoSize(const CScript &script_pub_key)
Definition: coinstats.cpp:20
CoinStatsHashType
Definition: coinstats.h:22
bool GetUTXOStats(CCoinsView *view, BlockManager &blockman, CCoinsStats &stats, const std::function< void()> &interruption_point={}, const CBlockIndex *pindex=nullptr)
Calculate statistics about the unspent transaction output set.
Definition: coinstats.cpp:146
Definition: amount.h:19
static constexpr Amount zero()
Definition: amount.h:42
A BlockHash is a unqiue identifier for a block.
Definition: blockhash.h:13
uint64_t nTransactionOutputs
Definition: coinstats.h:33
Amount total_new_outputs_ex_coinbase_amount
Definition: coinstats.h:51
uint64_t nTransactions
Definition: coinstats.h:32
uint256 hashSerialized
Definition: coinstats.h:35
bool index_used
Signals if the coinstatsindex was used to retrieve the statistics.
Definition: coinstats.h:45
bool index_requested
Signals if the coinstatsindex should be used (when available).
Definition: coinstats.h:43
Amount total_prevout_spent_amount
Definition: coinstats.h:50
BlockHash hashBlock
Definition: coinstats.h:31
uint64_t nBogoSize
Definition: coinstats.h:34
Amount total_unspendables_genesis_block
Definition: coinstats.h:53
int nHeight
Definition: coinstats.h:30
uint64_t nDiskSize
Definition: coinstats.h:36
CCoinsStats(CoinStatsHashType hash_type)
Definition: coinstats.h:58
uint64_t coins_count
The number of coins contained.
Definition: coinstats.h:40
Amount total_unspendables_unclaimed_rewards
Definition: coinstats.h:56
Amount nTotalAmount
Definition: coinstats.h:37
Amount total_subsidy
Definition: coinstats.h:48
Amount total_unspendable_amount
Definition: coinstats.h:49
Amount total_unspendables_scripts
Definition: coinstats.h:55
Amount total_unspendables_bip30
Definition: coinstats.h:54
Amount total_coinbase_amount
Definition: coinstats.h:52
CoinStatsHashType m_hash_type
Definition: coinstats.h:29