aboutsummaryrefslogtreecommitdiff
path: root/src/node
diff options
context:
space:
mode:
authorFabian Jahr <fjahr@protonmail.com>2021-02-21 23:24:28 +0100
committerFabian Jahr <fjahr@protonmail.com>2021-04-19 20:28:48 +0200
commit9c8a265fd21a87228c18a1661df99fedc1866baf (patch)
tree416934f0681eb9ffb00a08269a63b72292a3bbbc /src/node
parent2e2648a9021dfbb6e17dfa81472f057dacbc34e0 (diff)
downloadbitcoin-9c8a265fd21a87228c18a1661df99fedc1866baf.tar.xz
refactor: Pass hash_type to CoinsStats in stats object
Diffstat (limited to 'src/node')
-rw-r--r--src/node/coinstats.cpp5
-rw-r--r--src/node/coinstats.h5
2 files changed, 6 insertions, 4 deletions
diff --git a/src/node/coinstats.cpp b/src/node/coinstats.cpp
index f8f0fff43f..c52b718b22 100644
--- a/src/node/coinstats.cpp
+++ b/src/node/coinstats.cpp
@@ -86,7 +86,6 @@ static void ApplyStats(CCoinsStats& stats, T& hash_obj, const uint256& hash, con
template <typename T>
static bool GetUTXOStats(CCoinsView* view, BlockManager& blockman, CCoinsStats& stats, T hash_obj, const std::function<void()>& interruption_point)
{
- stats = CCoinsStats();
std::unique_ptr<CCoinsViewCursor> pcursor(view->Cursor());
assert(pcursor);
@@ -129,9 +128,9 @@ static bool GetUTXOStats(CCoinsView* view, BlockManager& blockman, CCoinsStats&
return true;
}
-bool GetUTXOStats(CCoinsView* view, BlockManager& blockman, CCoinsStats& stats, CoinStatsHashType hash_type, const std::function<void()>& interruption_point)
+bool GetUTXOStats(CCoinsView* view, BlockManager& blockman, CCoinsStats& stats, const std::function<void()>& interruption_point)
{
- switch (hash_type) {
+ switch (stats.m_hash_type) {
case(CoinStatsHashType::HASH_SERIALIZED): {
CHashWriter ss(SER_GETHASH, PROTOCOL_VERSION);
return GetUTXOStats(view, blockman, stats, ss, interruption_point);
diff --git a/src/node/coinstats.h b/src/node/coinstats.h
index 975651dcc4..85896a2a1d 100644
--- a/src/node/coinstats.h
+++ b/src/node/coinstats.h
@@ -23,6 +23,7 @@ enum class CoinStatsHashType {
struct CCoinsStats
{
+ CoinStatsHashType m_hash_type;
int nHeight{0};
uint256 hashBlock{};
uint64_t nTransactions{0};
@@ -34,9 +35,11 @@ struct CCoinsStats
//! The number of coins contained.
uint64_t coins_count{0};
+
+ CCoinsStats(CoinStatsHashType hash_type) : m_hash_type(hash_type) {}
};
//! Calculate statistics about the unspent transaction output set
-bool GetUTXOStats(CCoinsView* view, BlockManager& blockman, CCoinsStats& stats, const CoinStatsHashType hash_type, const std::function<void()>& interruption_point = {});
+bool GetUTXOStats(CCoinsView* view, BlockManager& blockman, CCoinsStats& stats, const std::function<void()>& interruption_point = {});
#endif // BITCOIN_NODE_COINSTATS_H