Branch data Line data Source code
# 1 : : // Copyright (c) 2010 Satoshi Nakamoto # 2 : : // Copyright (c) 2009-2021 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 <streams.h> # 13 : : #include <uint256.h> # 14 : : # 15 : : #include <cstdint> # 16 : : #include <functional> # 17 : : # 18 : : class CCoinsView; # 19 : : namespace node { # 20 : : class BlockManager; # 21 : : } // namespace node # 22 : : # 23 : : namespace node { # 24 : : enum class CoinStatsHashType { # 25 : : HASH_SERIALIZED, # 26 : : MUHASH, # 27 : : NONE, # 28 : : }; # 29 : : # 30 : : struct CCoinsStats { # 31 : : //! Which hash type to use # 32 : : const CoinStatsHashType m_hash_type; # 33 : : # 34 : : int nHeight{0}; # 35 : : uint256 hashBlock{}; # 36 : : uint64_t nTransactions{0}; # 37 : : uint64_t nTransactionOutputs{0}; # 38 : : uint64_t nBogoSize{0}; # 39 : : uint256 hashSerialized{}; # 40 : : uint64_t nDiskSize{0}; # 41 : : //! The total amount, or nullopt if an overflow occurred calculating it # 42 : : std::optional<CAmount> total_amount{0}; # 43 : : # 44 : : //! The number of coins contained. # 45 : : uint64_t coins_count{0}; # 46 : : # 47 : : //! Signals if the coinstatsindex should be used (when available). # 48 : : bool index_requested{true}; # 49 : : //! Signals if the coinstatsindex was used to retrieve the statistics. # 50 : : bool index_used{false}; # 51 : : # 52 : : // Following values are only available from coinstats index # 53 : : # 54 : : //! Total cumulative amount of block subsidies up to and including this block # 55 : : CAmount total_subsidy{0}; # 56 : : //! Total cumulative amount of unspendable coins up to and including this block # 57 : : CAmount total_unspendable_amount{0}; # 58 : : //! Total cumulative amount of prevouts spent up to and including this block # 59 : : CAmount total_prevout_spent_amount{0}; # 60 : : //! Total cumulative amount of outputs created up to and including this block # 61 : : CAmount total_new_outputs_ex_coinbase_amount{0}; # 62 : : //! Total cumulative amount of coinbase outputs up to and including this block # 63 : : CAmount total_coinbase_amount{0}; # 64 : : //! The unspendable coinbase amount from the genesis block # 65 : : CAmount total_unspendables_genesis_block{0}; # 66 : : //! The two unspendable coinbase outputs total amount caused by BIP30 # 67 : : CAmount total_unspendables_bip30{0}; # 68 : : //! Total cumulative amount of outputs sent to unspendable scripts (OP_RETURN for example) up to and including this block # 69 : : CAmount total_unspendables_scripts{0}; # 70 : : //! Total cumulative amount of coins lost due to unclaimed miner rewards up to and including this block # 71 : : CAmount total_unspendables_unclaimed_rewards{0}; # 72 : : # 73 : 81 : CCoinsStats(CoinStatsHashType hash_type) : m_hash_type(hash_type) {} # 74 : : }; # 75 : : # 76 : : //! Calculate statistics about the unspent transaction output set # 77 : : bool GetUTXOStats(CCoinsView* view, node::BlockManager& blockman, CCoinsStats& stats, const std::function<void()>& interruption_point = {}, const CBlockIndex* pindex = nullptr); # 78 : : # 79 : : uint64_t GetBogoSize(const CScript& script_pub_key); # 80 : : # 81 : : CDataStream TxOutSer(const COutPoint& outpoint, const Coin& coin); # 82 : : } // namespace node # 83 : : # 84 : : #endif // BITCOIN_NODE_COINSTATS_H