Skip to content

Commit d6d2c85

Browse files
author
MarcoFalke
committed
Merge #11340: Trivial: Fix validation comments
a0b4c24 Trivial: Fix validation comments (Dan Raviv) Pull request description: - 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. Tree-SHA512: ff86ff02c993e8317b9a0decfe5f5b6aae77b7d50e2b253ed73eb553348142bfc30cfeda15fae91907bab8f920e0ea7c52714f4cc7f33a9d6a777f708e2c99ba
2 parents e278f86 + a0b4c24 commit d6d2c85

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

src/consensus/validation.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,17 +89,16 @@ class CValidationState {
8989
std::string GetDebugMessage() const { return strDebugMessage; }
9090
};
9191

92+
// These implement the weight = (stripped_size * 4) + witness_size formula,
93+
// using only serialization with and without witness data. As witness_size
94+
// is equal to total_size - stripped_size, this formula is identical to:
95+
// weight = (stripped_size * 3) + total_size.
9296
static inline int64_t GetTransactionWeight(const CTransaction& tx)
9397
{
94-
return ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION | SERIALIZE_TRANSACTION_NO_WITNESS) * (WITNESS_SCALE_FACTOR -1) + ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION);
98+
return ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION | SERIALIZE_TRANSACTION_NO_WITNESS) * (WITNESS_SCALE_FACTOR - 1) + ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION);
9599
}
96-
97100
static inline int64_t GetBlockWeight(const CBlock& block)
98101
{
99-
// This implements the weight = (stripped_size * 4) + witness_size formula,
100-
// using only serialization with and without witness data. As witness_size
101-
// is equal to total_size - stripped_size, this formula is identical to:
102-
// weight = (stripped_size * 3) + total_size.
103102
return ::GetSerializeSize(block, SER_NETWORK, PROTOCOL_VERSION | SERIALIZE_TRANSACTION_NO_WITNESS) * (WITNESS_SCALE_FACTOR - 1) + ::GetSerializeSize(block, SER_NETWORK, PROTOCOL_VERSION);
104103
}
105104

src/validation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ bool CheckFinalTx(const CTransaction &tx, int flags)
219219
// IsFinalTx() with one more than chainActive.Height().
220220
const int nBlockHeight = chainActive.Height() + 1;
221221

222-
// BIP113 will require that time-locked transactions have nLockTime set to
222+
// BIP113 requires that time-locked transactions have nLockTime set to
223223
// less than the median time of the previous block they're contained in.
224224
// When the next block is created its previous block will be the current
225225
// chain tip, so we use that to calculate the median time passed to

src/validation.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ static const int MAX_CMPCTBLOCK_DEPTH = 5;
9494
static const int MAX_BLOCKTXN_DEPTH = 10;
9595
/** Size of the "block download window": how far ahead of our current height do we fetch?
9696
* Larger windows tolerate larger download speed differences between peer, but increase the potential
97-
* degree of disordering of blocks on disk (which make reindexing and in the future perhaps pruning
98-
* harder). We'll probably want to make this a per-peer adaptive value at some point. */
97+
* degree of disordering of blocks on disk (which make reindexing and pruning harder). We'll probably
98+
* want to make this a per-peer adaptive value at some point. */
9999
static const unsigned int BLOCK_DOWNLOAD_WINDOW = 1024;
100100
/** Time to wait (in seconds) between writing blocks/block index to disk. */
101101
static const unsigned int DATABASE_WRITE_INTERVAL = 60 * 60;

0 commit comments

Comments
 (0)