2019-03-28 12:41:01 -03:00
|
|
|
// Copyright (c) 2010 Satoshi Nakamoto
|
2020-12-31 05:48:25 -03:00
|
|
|
// Copyright (c) 2009-2020 The Bitcoin Core developers
|
2019-03-28 12:41:01 -03:00
|
|
|
// Distributed under the MIT software license, see the accompanying
|
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
|
|
|
|
#ifndef BITCOIN_NODE_COINSTATS_H
|
|
|
|
#define BITCOIN_NODE_COINSTATS_H
|
|
|
|
|
|
|
|
#include <amount.h>
|
2020-01-24 14:56:47 -03:00
|
|
|
#include <chain.h>
|
|
|
|
#include <coins.h>
|
|
|
|
#include <streams.h>
|
2019-03-28 12:41:01 -03:00
|
|
|
#include <uint256.h>
|
|
|
|
|
|
|
|
#include <cstdint>
|
2020-05-22 16:09:34 -04:00
|
|
|
#include <functional>
|
2019-03-28 12:41:01 -03:00
|
|
|
|
2021-03-17 17:53:54 -03:00
|
|
|
class BlockManager;
|
2019-03-28 12:41:01 -03:00
|
|
|
class CCoinsView;
|
|
|
|
|
2020-06-02 17:52:34 -04:00
|
|
|
enum class CoinStatsHashType {
|
|
|
|
HASH_SERIALIZED,
|
2020-06-02 17:55:32 -04:00
|
|
|
MUHASH,
|
2020-06-02 17:56:28 -04:00
|
|
|
NONE,
|
2020-06-02 17:52:34 -04:00
|
|
|
};
|
|
|
|
|
2019-03-28 12:41:01 -03:00
|
|
|
struct CCoinsStats
|
|
|
|
{
|
2021-02-21 19:24:28 -03:00
|
|
|
CoinStatsHashType m_hash_type;
|
2019-03-28 13:09:06 -03:00
|
|
|
int nHeight{0};
|
|
|
|
uint256 hashBlock{};
|
|
|
|
uint64_t nTransactions{0};
|
|
|
|
uint64_t nTransactionOutputs{0};
|
|
|
|
uint64_t nBogoSize{0};
|
|
|
|
uint256 hashSerialized{};
|
|
|
|
uint64_t nDiskSize{0};
|
|
|
|
CAmount nTotalAmount{0};
|
|
|
|
|
|
|
|
//! The number of coins contained.
|
|
|
|
uint64_t coins_count{0};
|
2021-02-21 19:24:28 -03:00
|
|
|
|
2021-02-28 15:27:00 -03:00
|
|
|
//! Signals if the coinstatsindex should be used (when available).
|
|
|
|
bool index_requested{true};
|
|
|
|
//! Signals if the coinstatsindex was used to retrieve the statistics.
|
|
|
|
bool index_used{false};
|
2020-05-15 10:14:07 -04:00
|
|
|
|
2020-08-22 14:21:20 -04:00
|
|
|
// Following values are only available from coinstats index
|
2021-06-02 20:06:00 -04:00
|
|
|
|
|
|
|
//! Total cumulative amount of block subsidies up to and including this block
|
2020-08-22 14:21:20 -04:00
|
|
|
CAmount total_subsidy{0};
|
2021-06-02 20:06:00 -04:00
|
|
|
//! Total cumulative amount of unspendable coins up to and including this block
|
2021-06-02 19:31:47 -04:00
|
|
|
CAmount total_unspendable_amount{0};
|
2021-06-02 20:06:00 -04:00
|
|
|
//! Total cumulative amount of prevouts spent up to and including this block
|
2021-06-02 19:31:47 -04:00
|
|
|
CAmount total_prevout_spent_amount{0};
|
2021-06-02 20:06:00 -04:00
|
|
|
//! Total cumulative amount of outputs created up to and including this block
|
2021-06-02 19:31:47 -04:00
|
|
|
CAmount total_new_outputs_ex_coinbase_amount{0};
|
2021-06-02 20:06:00 -04:00
|
|
|
//! Total cumulative amount of coinbase outputs up to and including this block
|
2021-06-02 19:31:47 -04:00
|
|
|
CAmount total_coinbase_amount{0};
|
2021-06-02 20:06:00 -04:00
|
|
|
//! The unspendable coinbase amount from the genesis block
|
2021-06-02 19:31:47 -04:00
|
|
|
CAmount total_unspendables_genesis_block{0};
|
2021-06-02 20:06:00 -04:00
|
|
|
//! The two unspendable coinbase outputs total amount caused by BIP30
|
2021-06-02 19:31:47 -04:00
|
|
|
CAmount total_unspendables_bip30{0};
|
2021-06-02 20:06:00 -04:00
|
|
|
//! Total cumulative amount of outputs sent to unspendable scripts (OP_RETURN for example) up to and including this block
|
2021-06-02 19:31:47 -04:00
|
|
|
CAmount total_unspendables_scripts{0};
|
2021-06-02 20:06:00 -04:00
|
|
|
//! Total cumulative amount of coins lost due to unclaimed miner rewards up to and including this block
|
2021-06-02 19:31:47 -04:00
|
|
|
CAmount total_unspendables_unclaimed_rewards{0};
|
2020-08-22 14:21:20 -04:00
|
|
|
|
2021-02-21 19:24:28 -03:00
|
|
|
CCoinsStats(CoinStatsHashType hash_type) : m_hash_type(hash_type) {}
|
2019-03-28 12:41:01 -03:00
|
|
|
};
|
|
|
|
|
|
|
|
//! Calculate statistics about the unspent transaction output set
|
2020-05-15 10:14:07 -04:00
|
|
|
bool GetUTXOStats(CCoinsView* view, BlockManager& blockman, CCoinsStats& stats, const std::function<void()>& interruption_point = {}, const CBlockIndex* pindex = nullptr);
|
2019-03-28 12:41:01 -03:00
|
|
|
|
2020-01-24 14:56:47 -03:00
|
|
|
uint64_t GetBogoSize(const CScript& script_pub_key);
|
|
|
|
|
|
|
|
CDataStream TxOutSer(const COutPoint& outpoint, const Coin& coin);
|
|
|
|
|
2019-03-28 12:41:01 -03:00
|
|
|
#endif // BITCOIN_NODE_COINSTATS_H
|