From a0b4c2461724e9ec70e6cd3e36929c9270ffcebd Mon Sep 17 00:00:00 2001 From: Dan Raviv Date: Thu, 14 Sep 2017 17:59:09 +0300 Subject: Trivial: Fix validation comments - Move comment about transaction/block weight calculation so it applies not only to the GetBlockWeight function but also to GetTransactionWeight - Fix comment in validation.cpp referencing future deployment of BIP113. It has already been deployed. - The doc comment for BLOCK_DOWNLOAD_WINDOW wasn't updated since pruning was introduced, so it still refers to pruning as something that might happen in the future. A larger BLOCK_DOWNLOAD_WINDOW window would now, indeed, make pruning harder. --- src/consensus/validation.h | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'src/consensus') diff --git a/src/consensus/validation.h b/src/consensus/validation.h index 5494ce40ea..b6740c9d9f 100644 --- a/src/consensus/validation.h +++ b/src/consensus/validation.h @@ -89,17 +89,16 @@ public: std::string GetDebugMessage() const { return strDebugMessage; } }; +// 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. static inline int64_t GetTransactionWeight(const CTransaction& tx) { - return ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION | SERIALIZE_TRANSACTION_NO_WITNESS) * (WITNESS_SCALE_FACTOR -1) + ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION); + return ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION | SERIALIZE_TRANSACTION_NO_WITNESS) * (WITNESS_SCALE_FACTOR - 1) + ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION); } - static inline int64_t GetBlockWeight(const CBlock& block) { - // This implements 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. return ::GetSerializeSize(block, SER_NETWORK, PROTOCOL_VERSION | SERIALIZE_TRANSACTION_NO_WITNESS) * (WITNESS_SCALE_FACTOR - 1) + ::GetSerializeSize(block, SER_NETWORK, PROTOCOL_VERSION); } -- cgit v1.2.3