diff options
author | Pieter Wuille <pieter.wuille@gmail.com> | 2016-01-03 18:54:50 +0100 |
---|---|---|
committer | Pieter Wuille <pieter.wuille@gmail.com> | 2016-06-22 15:43:00 +0200 |
commit | 2b1f6f9ccf36f1e0a2c9d99154e1642f796d7c2b (patch) | |
tree | 30b17fa55ea6c9ae0055c0c16d2e271a0c799d16 /src/primitives/block.cpp | |
parent | 7c4bf779e8b74e474551982a24f5acc265293abd (diff) |
BIP141: Other consensus critical limits, and BIP145
Includes changes by Suhas Daftuar, Luke-jr, and mruddy.
Diffstat (limited to 'src/primitives/block.cpp')
-rw-r--r-- | src/primitives/block.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/primitives/block.cpp b/src/primitives/block.cpp index 6fb33230a5..df900388f2 100644 --- a/src/primitives/block.cpp +++ b/src/primitives/block.cpp @@ -31,3 +31,12 @@ std::string CBlock::ToString() const } return s.str(); } + +int64_t GetBlockCost(const CBlock& block) +{ + // This implements the cost = (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. + return ::GetSerializeSize(block, SER_NETWORK, PROTOCOL_VERSION | SERIALIZE_TRANSACTION_NO_WITNESS) * (WITNESS_SCALE_FACTOR - 1) + ::GetSerializeSize(block, SER_NETWORK, PROTOCOL_VERSION); +} |