aboutsummaryrefslogtreecommitdiff
path: root/src/node
diff options
context:
space:
mode:
authorFabian Jahr <fjahr@protonmail.com>2020-06-02 23:41:04 +0200
committerFabian Jahr <fjahr@protonmail.com>2020-06-19 14:13:08 +0200
commit605884ef21318fc3f326dbdf4901cb353ba63fab (patch)
treefd8bdd87fb393994b82a852c37ede33462434277 /src/node
parentb33136b6ba9887f7db651c4c5264ca7f2f601df7 (diff)
refactor: Extract GetBogoSize function
Diffstat (limited to 'src/node')
-rw-r--r--src/node/coinstats.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/node/coinstats.cpp b/src/node/coinstats.cpp
index e3c4c828b6..faa62420cd 100644
--- a/src/node/coinstats.cpp
+++ b/src/node/coinstats.cpp
@@ -8,12 +8,22 @@
#include <coins.h>
#include <hash.h>
#include <serialize.h>
-#include <validation.h>
#include <uint256.h>
#include <util/system.h>
+#include <validation.h>
#include <map>
+static uint64_t GetBogoSize(const CScript& scriptPubKey)
+{
+ return 32 /* txid */ +
+ 4 /* vout index */ +
+ 4 /* height + coinbase */ +
+ 8 /* amount */ +
+ 2 /* scriptPubKey len */ +
+ scriptPubKey.size() /* scriptPubKey */;
+}
+
static void ApplyStats(CCoinsStats &stats, CHashWriter& ss, const uint256& hash, const std::map<uint32_t, Coin>& outputs)
{
assert(!outputs.empty());
@@ -26,8 +36,7 @@ static void ApplyStats(CCoinsStats &stats, CHashWriter& ss, const uint256& hash,
ss << VARINT_MODE(output.second.out.nValue, VarIntMode::NONNEGATIVE_SIGNED);
stats.nTransactionOutputs++;
stats.nTotalAmount += output.second.out.nValue;
- stats.nBogoSize += 32 /* txid */ + 4 /* vout index */ + 4 /* height + coinbase */ + 8 /* amount */ +
- 2 /* scriptPubKey len */ + output.second.out.scriptPubKey.size() /* scriptPubKey */;
+ stats.nBogoSize += GetBogoSize(output.second.out.scriptPubKey);
}
ss << VARINT(0u);
}