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.
This commit is contained in:
parent
09627b1dd4
commit
a0b4c24617
3 changed files with 8 additions and 9 deletions
|
@ -89,17 +89,16 @@ public:
|
||||||
std::string GetDebugMessage() const { return strDebugMessage; }
|
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)
|
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)
|
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);
|
return ::GetSerializeSize(block, SER_NETWORK, PROTOCOL_VERSION | SERIALIZE_TRANSACTION_NO_WITNESS) * (WITNESS_SCALE_FACTOR - 1) + ::GetSerializeSize(block, SER_NETWORK, PROTOCOL_VERSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -219,7 +219,7 @@ bool CheckFinalTx(const CTransaction &tx, int flags)
|
||||||
// IsFinalTx() with one more than chainActive.Height().
|
// IsFinalTx() with one more than chainActive.Height().
|
||||||
const int nBlockHeight = chainActive.Height() + 1;
|
const int nBlockHeight = chainActive.Height() + 1;
|
||||||
|
|
||||||
// BIP113 will require that time-locked transactions have nLockTime set to
|
// BIP113 requires that time-locked transactions have nLockTime set to
|
||||||
// less than the median time of the previous block they're contained in.
|
// less than the median time of the previous block they're contained in.
|
||||||
// When the next block is created its previous block will be the current
|
// When the next block is created its previous block will be the current
|
||||||
// chain tip, so we use that to calculate the median time passed to
|
// chain tip, so we use that to calculate the median time passed to
|
||||||
|
|
|
@ -94,8 +94,8 @@ static const int MAX_CMPCTBLOCK_DEPTH = 5;
|
||||||
static const int MAX_BLOCKTXN_DEPTH = 10;
|
static const int MAX_BLOCKTXN_DEPTH = 10;
|
||||||
/** Size of the "block download window": how far ahead of our current height do we fetch?
|
/** Size of the "block download window": how far ahead of our current height do we fetch?
|
||||||
* Larger windows tolerate larger download speed differences between peer, but increase the potential
|
* Larger windows tolerate larger download speed differences between peer, but increase the potential
|
||||||
* degree of disordering of blocks on disk (which make reindexing and in the future perhaps pruning
|
* degree of disordering of blocks on disk (which make reindexing and pruning harder). We'll probably
|
||||||
* harder). We'll probably want to make this a per-peer adaptive value at some point. */
|
* want to make this a per-peer adaptive value at some point. */
|
||||||
static const unsigned int BLOCK_DOWNLOAD_WINDOW = 1024;
|
static const unsigned int BLOCK_DOWNLOAD_WINDOW = 1024;
|
||||||
/** Time to wait (in seconds) between writing blocks/block index to disk. */
|
/** Time to wait (in seconds) between writing blocks/block index to disk. */
|
||||||
static const unsigned int DATABASE_WRITE_INTERVAL = 60 * 60;
|
static const unsigned int DATABASE_WRITE_INTERVAL = 60 * 60;
|
||||||
|
|
Loading…
Reference in a new issue