Bitcoin Core
31.1.0
P2P Digital Currency
Toggle main menu visibility
Loading...
Searching...
No Matches
src
kernel
coinstats.h
Go to the documentation of this file.
1
// Copyright (c) 2022-present 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 <
uint256.h
>
11
12
#include <cstdint>
13
#include <functional>
14
#include <optional>
15
16
class
CCoinsView
;
17
class
Coin
;
18
class
COutPoint
;
19
class
CScript
;
20
class
MuHash3072
;
21
namespace
node
{
22
class
BlockManager
;
23
}
// namespace node
24
25
namespace
kernel
{
26
enum class
CoinStatsHashType
{
27
HASH_SERIALIZED
,
28
MUHASH
,
29
NONE,
30
};
31
32
struct
CCoinsStats
{
33
int
nHeight
{0};
34
uint256
hashBlock
{};
35
uint64_t
nTransactions
{0};
36
uint64_t
nTransactionOutputs
{0};
37
uint64_t
nBogoSize
{0};
38
uint256
hashSerialized
{};
39
uint64_t
nDiskSize
{0};
41
std::optional<CAmount>
total_amount
{0};
42
44
uint64_t
coins_count
{0};
45
47
bool
index_used
{
false
};
48
49
// Following values are only available from coinstats index
50
52
CAmount
total_subsidy
{0};
54
CAmount
total_unspendables_genesis_block
{0};
56
CAmount
total_unspendables_bip30
{0};
58
CAmount
total_unspendables_scripts
{0};
60
CAmount
total_unspendables_unclaimed_rewards
{0};
61
62
// Despite containing amounts the following values use a uint256 type to prevent overflowing
63
65
arith_uint256
total_prevout_spent_amount
{0};
67
arith_uint256
total_new_outputs_ex_coinbase_amount
{0};
69
arith_uint256
total_coinbase_amount
{0};
70
71
CCoinsStats
() =
default
;
72
CCoinsStats
(
int
block_height,
const
uint256
& block_hash);
73
};
74
75
uint64_t
GetBogoSize
(
const
CScript
& script_pub_key);
76
77
void
ApplyCoinHash
(
MuHash3072
& muhash,
const
COutPoint
& outpoint,
const
Coin
& coin);
78
void
RemoveCoinHash
(
MuHash3072
& muhash,
const
COutPoint
& outpoint,
const
Coin
& coin);
79
80
std::optional<CCoinsStats>
ComputeUTXOStats
(
CoinStatsHashType
hash_type,
CCoinsView
* view,
node::BlockManager
& blockman,
const
std::function<
void
()>& interruption_point = {});
81
}
// namespace kernel
82
83
#endif
// BITCOIN_KERNEL_COINSTATS_H
amount.h
CAmount
int64_t CAmount
Amount in satoshis (Can be negative).
Definition
amount.h:12
arith_uint256.h
CCoinsView
Abstract view on the open txout dataset.
Definition
coins.h:308
COutPoint
An outpoint - a combination of a transaction hash and an index n into its vout.
Definition
transaction.h:29
CScript
Serialized script, used inside transaction inputs and outputs.
Definition
script.h:405
Coin
A UTXO entry.
Definition
coins.h:35
MuHash3072
A class representing MuHash sets.
Definition
muhash.h:103
arith_uint256
256-bit unsigned big integer.
Definition
arith_uint256.h:231
node::BlockManager
Maintains a tree of blocks (stored in m_block_index) which is consulted to determine where the most-w...
Definition
blockstorage.h:192
uint256
256-bit opaque blob.
Definition
uint256.h:195
kernel
Definition
coinstatsindex.h:21
kernel::ApplyCoinHash
void ApplyCoinHash(MuHash3072 &muhash, const COutPoint &outpoint, const Coin &coin)
Definition
coinstats.cpp:59
kernel::ComputeUTXOStats
std::optional< CCoinsStats > ComputeUTXOStats(CoinStatsHashType hash_type, CCoinsView *view, node::BlockManager &blockman, const std::function< void()> &interruption_point)
Definition
coinstats.cpp:149
kernel::RemoveCoinHash
void RemoveCoinHash(MuHash3072 &muhash, const COutPoint &outpoint, const Coin &coin)
Definition
coinstats.cpp:66
kernel::CoinStatsHashType
CoinStatsHashType
Definition
coinstats.h:26
kernel::CoinStatsHashType::HASH_SERIALIZED
@ HASH_SERIALIZED
Definition
coinstats.h:27
kernel::CoinStatsHashType::MUHASH
@ MUHASH
Definition
coinstats.h:28
kernel::GetBogoSize
uint64_t GetBogoSize(const CScript &script_pub_key)
Definition
coinstats.cpp:36
node
Definition
messages.h:21
CCoinsStats::CCoinsStats
CCoinsStats()=default
kernel::CCoinsStats::nHeight
int nHeight
Definition
coinstats.h:33
kernel::CCoinsStats::CCoinsStats
CCoinsStats()=default
kernel::CCoinsStats::total_prevout_spent_amount
arith_uint256 total_prevout_spent_amount
Total cumulative amount of prevouts spent up to and including this block.
Definition
coinstats.h:65
kernel::CCoinsStats::total_amount
std::optional< CAmount > total_amount
The total amount, or nullopt if an overflow occurred calculating it.
Definition
coinstats.h:41
kernel::CCoinsStats::nDiskSize
uint64_t nDiskSize
Definition
coinstats.h:39
kernel::CCoinsStats::total_unspendables_scripts
CAmount total_unspendables_scripts
Total cumulative amount of outputs sent to unspendable scripts (OP_RETURN for example) up to and incl...
Definition
coinstats.h:58
kernel::CCoinsStats::coins_count
uint64_t coins_count
The number of coins contained.
Definition
coinstats.h:44
kernel::CCoinsStats::nTransactions
uint64_t nTransactions
Definition
coinstats.h:35
kernel::CCoinsStats::total_coinbase_amount
arith_uint256 total_coinbase_amount
Total cumulative amount of coinbase outputs up to and including this block.
Definition
coinstats.h:69
kernel::CCoinsStats::nTransactionOutputs
uint64_t nTransactionOutputs
Definition
coinstats.h:36
kernel::CCoinsStats::nBogoSize
uint64_t nBogoSize
Definition
coinstats.h:37
kernel::CCoinsStats::index_used
bool index_used
Signals if the coinstatsindex was used to retrieve the statistics.
Definition
coinstats.h:47
kernel::CCoinsStats::total_unspendables_bip30
CAmount total_unspendables_bip30
The two unspendable coinbase outputs total amount caused by BIP30.
Definition
coinstats.h:56
kernel::CCoinsStats::total_unspendables_genesis_block
CAmount total_unspendables_genesis_block
The unspendable coinbase amount from the genesis block.
Definition
coinstats.h:54
kernel::CCoinsStats::hashBlock
uint256 hashBlock
Definition
coinstats.h:34
kernel::CCoinsStats::hashSerialized
uint256 hashSerialized
Definition
coinstats.h:38
kernel::CCoinsStats::total_new_outputs_ex_coinbase_amount
arith_uint256 total_new_outputs_ex_coinbase_amount
Total cumulative amount of outputs created up to and including this block.
Definition
coinstats.h:67
kernel::CCoinsStats::total_unspendables_unclaimed_rewards
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:60
kernel::CCoinsStats::total_subsidy
CAmount total_subsidy
Total cumulative amount of block subsidies up to and including this block.
Definition
coinstats.h:52
uint256.h
Generated on
for Bitcoin Core by
1.18.0