LCOV - code coverage report
Current view: top level - src/kernel - coinstats.h (source / functions) Hit Total Coverage
Test: fuzz_coverage.info Lines: 0 20 0.0 %
Date: 2023-11-10 23:46:46 Functions: 0 1 0.0 %
Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : // Copyright (c) 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_KERNEL_COINSTATS_H
       6                 :            : #define BITCOIN_KERNEL_COINSTATS_H
       7                 :            : 
       8                 :            : #include <consensus/amount.h>
       9                 :            : #include <crypto/muhash.h>
      10                 :            : #include <streams.h>
      11                 :            : #include <uint256.h>
      12                 :            : 
      13                 :            : #include <cstdint>
      14                 :            : #include <functional>
      15                 :            : #include <optional>
      16                 :            : 
      17                 :            : class CCoinsView;
      18                 :            : class Coin;
      19                 :            : class COutPoint;
      20                 :            : class CScript;
      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                 :          0 :     int nHeight{0};
      34                 :          0 :     uint256 hashBlock{};
      35                 :          0 :     uint64_t nTransactions{0};
      36                 :          0 :     uint64_t nTransactionOutputs{0};
      37                 :          0 :     uint64_t nBogoSize{0};
      38                 :          0 :     uint256 hashSerialized{};
      39                 :          0 :     uint64_t nDiskSize{0};
      40                 :            :     //! The total amount, or nullopt if an overflow occurred calculating it
      41                 :          0 :     std::optional<CAmount> total_amount{0};
      42                 :            : 
      43                 :            :     //! The number of coins contained.
      44                 :          0 :     uint64_t coins_count{0};
      45                 :            : 
      46                 :            :     //! Signals if the coinstatsindex was used to retrieve the statistics.
      47                 :          0 :     bool index_used{false};
      48                 :            : 
      49                 :            :     // Following values are only available from coinstats index
      50                 :            : 
      51                 :            :     //! Total cumulative amount of block subsidies up to and including this block
      52                 :          0 :     CAmount total_subsidy{0};
      53                 :            :     //! Total cumulative amount of unspendable coins up to and including this block
      54                 :          0 :     CAmount total_unspendable_amount{0};
      55                 :            :     //! Total cumulative amount of prevouts spent up to and including this block
      56                 :          0 :     CAmount total_prevout_spent_amount{0};
      57                 :            :     //! Total cumulative amount of outputs created up to and including this block
      58                 :          0 :     CAmount total_new_outputs_ex_coinbase_amount{0};
      59                 :            :     //! Total cumulative amount of coinbase outputs up to and including this block
      60                 :          0 :     CAmount total_coinbase_amount{0};
      61                 :            :     //! The unspendable coinbase amount from the genesis block
      62                 :          0 :     CAmount total_unspendables_genesis_block{0};
      63                 :            :     //! The two unspendable coinbase outputs total amount caused by BIP30
      64                 :          0 :     CAmount total_unspendables_bip30{0};
      65                 :            :     //! Total cumulative amount of outputs sent to unspendable scripts (OP_RETURN for example) up to and including this block
      66                 :          0 :     CAmount total_unspendables_scripts{0};
      67                 :            :     //! Total cumulative amount of coins lost due to unclaimed miner rewards up to and including this block
      68                 :          0 :     CAmount total_unspendables_unclaimed_rewards{0};
      69                 :            : 
      70                 :          0 :     CCoinsStats() = default;
      71                 :            :     CCoinsStats(int block_height, const uint256& block_hash);
      72                 :            : };
      73                 :            : 
      74                 :            : uint64_t GetBogoSize(const CScript& script_pub_key);
      75                 :            : 
      76                 :            : void ApplyCoinHash(MuHash3072& muhash, const COutPoint& outpoint, const Coin& coin);
      77                 :            : void RemoveCoinHash(MuHash3072& muhash, const COutPoint& outpoint, const Coin& coin);
      78                 :            : 
      79                 :            : std::optional<CCoinsStats> ComputeUTXOStats(CoinStatsHashType hash_type, CCoinsView* view, node::BlockManager& blockman, const std::function<void()>& interruption_point = {});
      80                 :            : } // namespace kernel
      81                 :            : 
      82                 :            : #endif // BITCOIN_KERNEL_COINSTATS_H

Generated by: LCOV version 1.14