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.
| 155 | // is equal to total_size - stripped_size, this formula is identical to: |
| 156 | // weight = (stripped_size * 3) + total_size. |
| 157 | static 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 | } |
| 161 | static 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; |
no test coverage detected