MCPcopy Create free account
hub / github.com/BTCGPU/BTCGPU / ApplyStats

Function ApplyStats

src/rpc/blockchain.cpp:908–924  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

906};
907
908static void ApplyStats(CCoinsStats &stats, CHashWriter& ss, const uint256& hash, const std::map<uint32_t, Coin>& outputs)
909{
910 assert(!outputs.empty());
911 ss << hash;
912 ss << VARINT(outputs.begin()->second.nHeight * 2 + outputs.begin()->second.fCoinBase ? 1u : 0u);
913 stats.nTransactions++;
914 for (const auto& output : outputs) {
915 ss << VARINT(output.first + 1);
916 ss << output.second.out.scriptPubKey;
917 ss << VARINT(output.second.out.nValue, VarIntMode::NONNEGATIVE_SIGNED);
918 stats.nTransactionOutputs++;
919 stats.nTotalAmount += output.second.out.nValue;
920 stats.nBogoSize += 32 /* txid */ + 4 /* vout index */ + 4 /* height + coinbase */ + 8 /* amount */ +
921 2 /* scriptPubKey len */ + output.second.out.scriptPubKey.size() /* scriptPubKey */;
922 }
923 ss << VARINT(0u);
924}
925
926//! Calculate statistics about the unspent transaction output set
927static bool GetUTXOStats(CCoinsView *view, CCoinsStats &stats)

Callers 1

GetUTXOStatsFunction · 0.85

Calls 3

emptyMethod · 0.45
beginMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected