mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-11 12:22:39 -03:00
fb65dde147
Initially these values were 'per block' in an earlier version but were then changed to total values. The names were not updated to reflect that. -BEGIN VERIFY SCRIPT- s() { git grep -l "$1" src | xargs sed -i "s/$1/$2/g"; } s 'm_block_unspendable_amount' 'm_total_unspendable_amount' s 'm_block_prevout_spent_amount' 'm_total_prevout_spent_amount' s 'm_block_new_outputs_ex_coinbase_amount' 'm_total_new_outputs_ex_coinbase_amount' s 'm_block_coinbase_amount' 'm_total_coinbase_amount' s 'block_unspendable_amount' 'total_unspendable_amount' s 'block_prevout_spent_amount' 'total_prevout_spent_amount' s 'block_new_outputs_ex_coinbase_amount' 'total_new_outputs_ex_coinbase_amount' s 'block_coinbase_amount' 'total_coinbase_amount' s 'unspendables_genesis_block' 'total_unspendables_genesis_block' s 'unspendables_bip30' 'total_unspendables_bip30' s 'unspendables_scripts' 'total_unspendables_scripts' s 'unspendables_unclaimed_rewards' 'total_unspendables_unclaimed_rewards' s 'm_unspendables_genesis_block' 'm_total_unspendables_genesis_block' s 'm_unspendables_bip30' 'm_total_unspendables_bip30' s 'm_unspendables_scripts' 'm_total_unspendables_scripts' s 'm_unspendables_unclaimed_rewards' 'm_total_unspendables_unclaimed_rewards' -END VERIFY SCRIPT-
61 lines
1.9 KiB
C++
61 lines
1.9 KiB
C++
// Copyright (c) 2020-2021 The Bitcoin Core developers
|
|
// Distributed under the MIT software license, see the accompanying
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
#ifndef BITCOIN_INDEX_COINSTATSINDEX_H
|
|
#define BITCOIN_INDEX_COINSTATSINDEX_H
|
|
|
|
#include <chain.h>
|
|
#include <crypto/muhash.h>
|
|
#include <flatfile.h>
|
|
#include <index/base.h>
|
|
#include <node/coinstats.h>
|
|
|
|
/**
|
|
* CoinStatsIndex maintains statistics on the UTXO set.
|
|
*/
|
|
class CoinStatsIndex final : public BaseIndex
|
|
{
|
|
private:
|
|
std::string m_name;
|
|
std::unique_ptr<BaseIndex::DB> m_db;
|
|
|
|
MuHash3072 m_muhash;
|
|
uint64_t m_transaction_output_count{0};
|
|
uint64_t m_bogo_size{0};
|
|
CAmount m_total_amount{0};
|
|
CAmount m_total_subsidy{0};
|
|
CAmount m_total_unspendable_amount{0};
|
|
CAmount m_total_prevout_spent_amount{0};
|
|
CAmount m_total_new_outputs_ex_coinbase_amount{0};
|
|
CAmount m_total_coinbase_amount{0};
|
|
CAmount m_total_unspendables_genesis_block{0};
|
|
CAmount m_total_unspendables_bip30{0};
|
|
CAmount m_total_unspendables_scripts{0};
|
|
CAmount m_total_unspendables_unclaimed_rewards{0};
|
|
|
|
bool ReverseBlock(const CBlock& block, const CBlockIndex* pindex);
|
|
|
|
protected:
|
|
bool Init() override;
|
|
|
|
bool WriteBlock(const CBlock& block, const CBlockIndex* pindex) override;
|
|
|
|
bool Rewind(const CBlockIndex* current_tip, const CBlockIndex* new_tip) override;
|
|
|
|
BaseIndex::DB& GetDB() const override { return *m_db; }
|
|
|
|
const char* GetName() const override { return "coinstatsindex"; }
|
|
|
|
public:
|
|
// Constructs the index, which becomes available to be queried.
|
|
explicit CoinStatsIndex(size_t n_cache_size, bool f_memory = false, bool f_wipe = false);
|
|
|
|
// Look up stats for a specific block using CBlockIndex
|
|
bool LookUpStats(const CBlockIndex* block_index, CCoinsStats& coins_stats) const;
|
|
};
|
|
|
|
/// The global UTXO set hash object.
|
|
extern std::unique_ptr<CoinStatsIndex> g_coin_stats_index;
|
|
|
|
#endif // BITCOIN_INDEX_COINSTATSINDEX_H
|