Rename "block cost" to "block weight"

Github-Pull: #8363
Rebased-From: 2c06bae39edfaa9c0855d83377ad8fda09e4fa08
This commit is contained in:
Suhas Daftuar
2016-07-18 13:28:26 -04:00
committed by Wladimir J. van der Laan
parent a07c8a032c
commit fca1a415ce
18 changed files with 69 additions and 69 deletions

View File

@@ -32,11 +32,11 @@ std::string CBlock::ToString() const
return s.str();
}
int64_t GetBlockCost(const CBlock& block)
int64_t GetBlockWeight(const CBlock& block)
{
// This implements the cost = (stripped_size * 4) + witness_size formula,
// 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:
// cost = (stripped_size * 3) + total_size.
// 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);
}

View File

@@ -154,7 +154,7 @@ struct CBlockLocator
}
};
/** Compute the consensus-critical block cost (see BIP 141). */
int64_t GetBlockCost(const CBlock& tx);
/** Compute the consensus-critical block weight (see BIP 141). */
int64_t GetBlockWeight(const CBlock& tx);
#endif // BITCOIN_PRIMITIVES_BLOCK_H

View File

@@ -121,7 +121,7 @@ unsigned int CTransaction::CalculateModifiedSize(unsigned int nTxSize) const
// Providing any more cleanup incentive than making additional inputs free would
// risk encouraging people to create junk outputs to redeem later.
if (nTxSize == 0)
nTxSize = (GetTransactionCost(*this) + WITNESS_SCALE_FACTOR - 1) / WITNESS_SCALE_FACTOR;
nTxSize = (GetTransactionWeight(*this) + WITNESS_SCALE_FACTOR - 1) / WITNESS_SCALE_FACTOR;
for (std::vector<CTxIn>::const_iterator it(vin.begin()); it != vin.end(); ++it)
{
unsigned int offset = 41U + std::min(110U, (unsigned int)it->scriptSig.size());
@@ -149,7 +149,7 @@ std::string CTransaction::ToString() const
return str;
}
int64_t GetTransactionCost(const CTransaction& tx)
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);
}

View File

@@ -459,7 +459,7 @@ struct CMutableTransaction
uint256 GetHash() const;
};
/** Compute the cost of a transaction, as defined by BIP 141 */
int64_t GetTransactionCost(const CTransaction &tx);
/** Compute the weight of a transaction, as defined by BIP 141 */
int64_t GetTransactionWeight(const CTransaction &tx);
#endif // BITCOIN_PRIMITIVES_TRANSACTION_H