Skip to content

Commit 605884e

Browse files
committed
refactor: Extract GetBogoSize function
1 parent b33136b commit 605884e

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/node/coinstats.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,22 @@
88
#include <coins.h>
99
#include <hash.h>
1010
#include <serialize.h>
11-
#include <validation.h>
1211
#include <uint256.h>
1312
#include <util/system.h>
13+
#include <validation.h>
1414

1515
#include <map>
1616

17+
static uint64_t GetBogoSize(const CScript& scriptPubKey)
18+
{
19+
return 32 /* txid */ +
20+
4 /* vout index */ +
21+
4 /* height + coinbase */ +
22+
8 /* amount */ +
23+
2 /* scriptPubKey len */ +
24+
scriptPubKey.size() /* scriptPubKey */;
25+
}
26+
1727
static void ApplyStats(CCoinsStats &stats, CHashWriter& ss, const uint256& hash, const std::map<uint32_t, Coin>& outputs)
1828
{
1929
assert(!outputs.empty());
@@ -26,8 +36,7 @@ static void ApplyStats(CCoinsStats &stats, CHashWriter& ss, const uint256& hash,
2636
ss << VARINT_MODE(output.second.out.nValue, VarIntMode::NONNEGATIVE_SIGNED);
2737
stats.nTransactionOutputs++;
2838
stats.nTotalAmount += output.second.out.nValue;
29-
stats.nBogoSize += 32 /* txid */ + 4 /* vout index */ + 4 /* height + coinbase */ + 8 /* amount */ +
30-
2 /* scriptPubKey len */ + output.second.out.scriptPubKey.size() /* scriptPubKey */;
39+
stats.nBogoSize += GetBogoSize(output.second.out.scriptPubKey);
3140
}
3241
ss << VARINT(0u);
3342
}

0 commit comments

Comments
 (0)