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

Function GetTransactionWeight

src/consensus/validation.h:157–160  ·  view source on GitHub ↗

These implement the weight = (stripped_size * 4) + witness_size formula, using only serialization with and without witness data. As witness_size is equal to total_size - stripped_size, this formula is identical to: weight = (stripped_size * 3) + total_size.

Source from the content-addressed store, hash-verified

155// is equal to total_size - stripped_size, this formula is identical to:
156// weight = (stripped_size * 3) + total_size.
157static inline int64_t GetTransactionWeight(const CTransaction& tx)
158{
159 return ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION | SERIALIZE_TRANSACTION_NO_WITNESS) * (WITNESS_SCALE_FACTOR - 1) + ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION);
160}
161static inline int64_t GetBlockWeight(const CBlock& block, const Consensus::Params& params)
162{
163 int ser_flag = (block.nHeight < (uint32_t)params.BTGHeight) ? SERIALIZE_BLOCK_LEGACY : 0;

Callers 8

TxToUnivFunction · 0.85
CTxMemPoolEntryMethod · 0.85
EXCLUSIVE_LOCKS_REQUIREDFunction · 0.85
IsStandardTxFunction · 0.85
CreateTransactionMethod · 0.85
getblocktemplateFunction · 0.85
getblockstatsFunction · 0.85

Calls 1

GetSerializeSizeFunction · 0.85

Tested by

no test coverage detected