aboutsummaryrefslogtreecommitdiff
path: root/src/node
diff options
context:
space:
mode:
authorFabian Jahr <fjahr@protonmail.com>2020-06-02 23:56:28 +0200
committerFabian Jahr <fjahr@protonmail.com>2020-06-22 01:55:36 +0200
commitf17a4d1c4ddce6935a353004898fb4e8618a213e (patch)
treeac02ebbe6cb4014da200bf3e466efd74468c521c /src/node
parenta712cf6f6801157667fcf36d1c498b6fff6d328a (diff)
downloadbitcoin-f17a4d1c4ddce6935a353004898fb4e8618a213e.tar.xz
rpc: Add hash_type NONE to gettxoutsetinfo
Diffstat (limited to 'src/node')
-rw-r--r--src/node/coinstats.cpp16
-rw-r--r--src/node/coinstats.h1
2 files changed, 17 insertions, 0 deletions
diff --git a/src/node/coinstats.cpp b/src/node/coinstats.cpp
index cc5e3cb627..fb46ea1731 100644
--- a/src/node/coinstats.cpp
+++ b/src/node/coinstats.cpp
@@ -41,6 +41,17 @@ static void ApplyStats(CCoinsStats& stats, CHashWriter& ss, const uint256& hash,
ss << VARINT(0u);
}
+static void ApplyStats(CCoinsStats& stats, std::nullptr_t, const uint256& hash, const std::map<uint32_t, Coin>& outputs)
+{
+ assert(!outputs.empty());
+ stats.nTransactions++;
+ for (const auto& output : outputs) {
+ stats.nTransactionOutputs++;
+ stats.nTotalAmount += output.second.out.nValue;
+ stats.nBogoSize += GetBogoSize(output.second.out.scriptPubKey);
+ }
+}
+
//! Calculate statistics about the unspent transaction output set
template <typename T>
static bool GetUTXOStats(CCoinsView* view, CCoinsStats& stats, T hash_obj, const std::function<void()>& interruption_point)
@@ -93,6 +104,9 @@ bool GetUTXOStats(CCoinsView* view, CCoinsStats& stats, CoinStatsHashType hash_t
CHashWriter ss(SER_GETHASH, PROTOCOL_VERSION);
return GetUTXOStats(view, stats, ss, interruption_point);
}
+ case(CoinStatsHashType::NONE): {
+ return GetUTXOStats(view, stats, nullptr, interruption_point);
+ }
} // no default case, so the compiler can warn about missing cases
assert(false);
}
@@ -102,8 +116,10 @@ static void PrepareHash(CHashWriter& ss, CCoinsStats& stats)
{
ss << stats.hashBlock;
}
+static void PrepareHash(std::nullptr_t, CCoinsStats& stats) {}
static void FinalizeHash(CHashWriter& ss, CCoinsStats& stats)
{
stats.hashSerialized = ss.GetHash();
}
+static void FinalizeHash(std::nullptr_t, CCoinsStats& stats) {}
diff --git a/src/node/coinstats.h b/src/node/coinstats.h
index 1d0270d56d..2a7441c10e 100644
--- a/src/node/coinstats.h
+++ b/src/node/coinstats.h
@@ -16,6 +16,7 @@ class CCoinsView;
enum class CoinStatsHashType {
HASH_SERIALIZED,
+ NONE,
};
struct CCoinsStats