fuzz coverage

Coverage Report

Created: 2025-10-29 15:27

/Users/eugenesiegel/btc/bitcoin/src/index/coinstatsindex.h
Line
Count
Source (jump to first uncovered line)
1
// Copyright (c) 2020-2022 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_INDEX_COINSTATSINDEX_H
6
#define BITCOIN_INDEX_COINSTATSINDEX_H
7
8
#include <arith_uint256.h>
9
#include <crypto/muhash.h>
10
#include <index/base.h>
11
12
class CBlockIndex;
13
class CDBBatch;
14
namespace kernel {
15
struct CCoinsStats;
16
}
17
18
static constexpr bool DEFAULT_COINSTATSINDEX{false};
19
20
/**
21
 * CoinStatsIndex maintains statistics on the UTXO set.
22
 */
23
class CoinStatsIndex final : public BaseIndex
24
{
25
private:
26
    std::unique_ptr<BaseIndex::DB> m_db;
27
28
    MuHash3072 m_muhash;
29
    uint64_t m_transaction_output_count{0};
30
    uint64_t m_bogo_size{0};
31
    CAmount m_total_amount{0};
32
    CAmount m_total_subsidy{0};
33
    arith_uint256 m_total_prevout_spent_amount{0};
34
    arith_uint256 m_total_new_outputs_ex_coinbase_amount{0};
35
    arith_uint256 m_total_coinbase_amount{0};
36
    CAmount m_total_unspendables_genesis_block{0};
37
    CAmount m_total_unspendables_bip30{0};
38
    CAmount m_total_unspendables_scripts{0};
39
    CAmount m_total_unspendables_unclaimed_rewards{0};
40
41
    uint256 m_current_block_hash{};
42
43
    [[nodiscard]] bool RevertBlock(const interfaces::BlockInfo& block);
44
45
0
    bool AllowPrune() const override { return true; }
46
47
protected:
48
    interfaces::Chain::NotifyOptions CustomOptions() override;
49
50
    bool CustomInit(const std::optional<interfaces::BlockRef>& block) override;
51
52
    bool CustomCommit(CDBBatch& batch) override;
53
54
    bool CustomAppend(const interfaces::BlockInfo& block) override;
55
56
    bool CustomRemove(const interfaces::BlockInfo& block) override;
57
58
0
    BaseIndex::DB& GetDB() const override { return *m_db; }
59
60
public:
61
    // Constructs the index, which becomes available to be queried.
62
    explicit CoinStatsIndex(std::unique_ptr<interfaces::Chain> chain, size_t n_cache_size, bool f_memory = false, bool f_wipe = false);
63
64
    // Look up stats for a specific block using CBlockIndex
65
    std::optional<kernel::CCoinsStats> LookUpStats(const CBlockIndex& block_index) const;
66
};
67
68
/// The global UTXO set hash object.
69
extern std::unique_ptr<CoinStatsIndex> g_coin_stats_index;
70
71
#endif // BITCOIN_INDEX_COINSTATSINDEX_H