diff --git a/src/node/coinstats.cpp b/src/node/coinstats.cpp --- a/src/node/coinstats.cpp +++ b/src/node/coinstats.cpp @@ -13,6 +13,12 @@ #include +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 &outputs) { assert(!outputs.empty()); @@ -27,10 +33,7 @@ VarIntMode::NONNEGATIVE_SIGNED); stats.nTransactionOutputs++; stats.nTotalAmount += output.second.GetTxOut().nValue; - stats.nBogoSize += - 32 /* txid */ + 4 /* vout index */ + 4 /* height + coinbase */ + - 8 /* amount */ + 2 /* scriptPubKey len */ + - output.second.GetTxOut().scriptPubKey.size() /* scriptPubKey */; + stats.nBogoSize += GetBogoSize(output.second.GetTxOut().scriptPubKey); } ss << VARINT(0u); }