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.
| 145 | // is equal to total_size - stripped_size, this formula is identical to: |
| 146 | // weight = (stripped_size * 3) + total_size. |
| 147 | static inline int64_t GetTransactionWeight(const CTransaction& tx) |
| 148 | { |
| 149 | return ::GetSerializeSize(tx, PROTOCOL_VERSION | SERIALIZE_TRANSACTION_NO_WITNESS) * (WITNESS_SCALE_FACTOR - 1) + ::GetSerializeSize(tx, PROTOCOL_VERSION); |
| 150 | } |
| 151 | static inline int64_t GetBlockWeight(const CBlock& block) |
| 152 | { |
| 153 | return ::GetSerializeSize(block, PROTOCOL_VERSION | SERIALIZE_TRANSACTION_NO_WITNESS) * (WITNESS_SCALE_FACTOR - 1) + ::GetSerializeSize(block, PROTOCOL_VERSION); |