aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Makefile.am1
-rw-r--r--src/kernel/coinstats.cpp2
-rw-r--r--src/kernel/coinstats.h78
-rw-r--r--src/node/coinstats.h56
4 files changed, 82 insertions, 55 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 005a91912c..ffbd5e9376 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -172,6 +172,7 @@ BITCOIN_CORE_H = \
interfaces/node.h \
interfaces/wallet.h \
kernel/chainstatemanager_opts.h \
+ kernel/coinstats.h \
key.h \
key_io.h \
logging.h \
diff --git a/src/kernel/coinstats.cpp b/src/kernel/coinstats.cpp
index 15d5c3fbe6..49db98d663 100644
--- a/src/kernel/coinstats.cpp
+++ b/src/kernel/coinstats.cpp
@@ -2,7 +2,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#include <node/coinstats.h>
+#include <kernel/coinstats.h>
#include <coins.h>
#include <crypto/muhash.h>
diff --git a/src/kernel/coinstats.h b/src/kernel/coinstats.h
new file mode 100644
index 0000000000..d470ea715a
--- /dev/null
+++ b/src/kernel/coinstats.h
@@ -0,0 +1,78 @@
+// Copyright (c) 2022 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_KERNEL_COINSTATS_H
+#define BITCOIN_KERNEL_COINSTATS_H
+
+#include <chain.h>
+#include <coins.h>
+#include <consensus/amount.h>
+#include <streams.h>
+#include <uint256.h>
+
+#include <cstdint>
+#include <functional>
+
+class CCoinsView;
+namespace node {
+class BlockManager;
+} // namespace node
+
+namespace node {
+enum class CoinStatsHashType {
+ HASH_SERIALIZED,
+ MUHASH,
+ NONE,
+};
+
+struct CCoinsStats {
+ int nHeight{0};
+ uint256 hashBlock{};
+ uint64_t nTransactions{0};
+ uint64_t nTransactionOutputs{0};
+ uint64_t nBogoSize{0};
+ uint256 hashSerialized{};
+ uint64_t nDiskSize{0};
+ //! The total amount, or nullopt if an overflow occurred calculating it
+ std::optional<CAmount> total_amount{0};
+
+ //! The number of coins contained.
+ uint64_t coins_count{0};
+
+ //! Signals if the coinstatsindex was used to retrieve the statistics.
+ bool index_used{false};
+
+ // Following values are only available from coinstats index
+
+ //! Total cumulative amount of block subsidies up to and including this block
+ CAmount total_subsidy{0};
+ //! Total cumulative amount of unspendable coins up to and including this block
+ CAmount total_unspendable_amount{0};
+ //! Total cumulative amount of prevouts spent up to and including this block
+ CAmount total_prevout_spent_amount{0};
+ //! Total cumulative amount of outputs created up to and including this block
+ CAmount total_new_outputs_ex_coinbase_amount{0};
+ //! Total cumulative amount of coinbase outputs up to and including this block
+ CAmount total_coinbase_amount{0};
+ //! The unspendable coinbase amount from the genesis block
+ CAmount total_unspendables_genesis_block{0};
+ //! The two unspendable coinbase outputs total amount caused by BIP30
+ CAmount total_unspendables_bip30{0};
+ //! Total cumulative amount of outputs sent to unspendable scripts (OP_RETURN for example) up to and including this block
+ CAmount total_unspendables_scripts{0};
+ //! Total cumulative amount of coins lost due to unclaimed miner rewards up to and including this block
+ CAmount total_unspendables_unclaimed_rewards{0};
+
+ CCoinsStats() = default;
+ CCoinsStats(int block_height, const uint256& block_hash);
+};
+
+uint64_t GetBogoSize(const CScript& script_pub_key);
+
+CDataStream TxOutSer(const COutPoint& outpoint, const Coin& coin);
+
+std::optional<CCoinsStats> ComputeUTXOStats(CoinStatsHashType hash_type, CCoinsView* view, node::BlockManager& blockman, const std::function<void()>& interruption_point = {});
+} // namespace node
+
+#endif // BITCOIN_KERNEL_COINSTATS_H
diff --git a/src/node/coinstats.h b/src/node/coinstats.h
index 8abf1e31e8..fbd5fd4067 100644
--- a/src/node/coinstats.h
+++ b/src/node/coinstats.h
@@ -6,6 +6,8 @@
#ifndef BITCOIN_NODE_COINSTATS_H
#define BITCOIN_NODE_COINSTATS_H
+#include <kernel/coinstats.h>
+
#include <chain.h>
#include <coins.h>
#include <consensus/amount.h>
@@ -21,54 +23,6 @@ class BlockManager;
} // namespace node
namespace node {
-enum class CoinStatsHashType {
- HASH_SERIALIZED,
- MUHASH,
- NONE,
-};
-
-struct CCoinsStats {
- int nHeight{0};
- uint256 hashBlock{};
- uint64_t nTransactions{0};
- uint64_t nTransactionOutputs{0};
- uint64_t nBogoSize{0};
- uint256 hashSerialized{};
- uint64_t nDiskSize{0};
- //! The total amount, or nullopt if an overflow occurred calculating it
- std::optional<CAmount> total_amount{0};
-
- //! The number of coins contained.
- uint64_t coins_count{0};
-
- //! Signals if the coinstatsindex was used to retrieve the statistics.
- bool index_used{false};
-
- // Following values are only available from coinstats index
-
- //! Total cumulative amount of block subsidies up to and including this block
- CAmount total_subsidy{0};
- //! Total cumulative amount of unspendable coins up to and including this block
- CAmount total_unspendable_amount{0};
- //! Total cumulative amount of prevouts spent up to and including this block
- CAmount total_prevout_spent_amount{0};
- //! Total cumulative amount of outputs created up to and including this block
- CAmount total_new_outputs_ex_coinbase_amount{0};
- //! Total cumulative amount of coinbase outputs up to and including this block
- CAmount total_coinbase_amount{0};
- //! The unspendable coinbase amount from the genesis block
- CAmount total_unspendables_genesis_block{0};
- //! The two unspendable coinbase outputs total amount caused by BIP30
- CAmount total_unspendables_bip30{0};
- //! Total cumulative amount of outputs sent to unspendable scripts (OP_RETURN for example) up to and including this block
- CAmount total_unspendables_scripts{0};
- //! Total cumulative amount of coins lost due to unclaimed miner rewards up to and including this block
- CAmount total_unspendables_unclaimed_rewards{0};
-
- CCoinsStats() = default;
- CCoinsStats(int block_height, const uint256& block_hash);
-};
-
/**
* Calculate statistics about the unspent transaction output set
*
@@ -79,12 +33,6 @@ std::optional<CCoinsStats> GetUTXOStats(CCoinsView* view, node::BlockManager& bl
const std::function<void()>& interruption_point = {},
const CBlockIndex* pindex = nullptr,
bool index_requested = true);
-
-uint64_t GetBogoSize(const CScript& script_pub_key);
-
-CDataStream TxOutSer(const COutPoint& outpoint, const Coin& coin);
-
-std::optional<CCoinsStats> ComputeUTXOStats(CoinStatsHashType hash_type, CCoinsView* view, BlockManager& blockman, const std::function<void()>& interruption_point = {});
} // namespace node
#endif // BITCOIN_NODE_COINSTATS_H