File tree Expand file tree Collapse file tree 2 files changed +10
-12
lines changed
Expand file tree Collapse file tree 2 files changed +10
-12
lines changed Original file line number Diff line number Diff line change 6767#include < any>
6868#include < memory>
6969#include < optional>
70- #include < stdexcept>
7170#include < utility>
7271
7372#include < boost/signals2/signal.hpp>
@@ -980,16 +979,6 @@ class MinerImpl : public Mining
980979
981980 std::unique_ptr<BlockTemplate> createNewBlock (BlockCreateOptions options) override
982981 {
983- // Reject too-small values instead of clamping so callers don't silently
984- // end up mining with different options than requested. This matches the
985- // behavior of the `-blockreservedweight` startup option, which rejects
986- // values below MINIMUM_BLOCK_RESERVED_WEIGHT.
987- if (options.block_reserved_weight && options.block_reserved_weight < MINIMUM_BLOCK_RESERVED_WEIGHT) {
988- throw std::runtime_error (strprintf (" block_reserved_weight (%zu) must be at least %u weight units" ,
989- *options.block_reserved_weight ,
990- MINIMUM_BLOCK_RESERVED_WEIGHT));
991- }
992-
993982 // Ensure m_tip_block is set so consumers of BlockTemplate can rely on that.
994983 if (!waitTipChanged (uint256::ZERO, MillisecondsDouble::max ())) return {};
995984 ApplyMiningDefaults (m_node.mining_args , options);
Original file line number Diff line number Diff line change 3030#include < algorithm>
3131#include < utility>
3232#include < numeric>
33+ #include < stdexcept>
3334
3435namespace node {
3536
@@ -81,7 +82,15 @@ static BlockCreateOptions ClampOptions(BlockCreateOptions options)
8182 // Typically block_reserved_weight and block_max_weight are set by
8283 // ApplyMiningDefaults before the constructor calls this; value_or(DEFAULT_...)
8384 // only affects (test) call sites that don't go through the Mining interface.
84- options.block_reserved_weight = std::clamp<size_t >(options.block_reserved_weight .value_or (DEFAULT_BLOCK_RESERVED_WEIGHT), MINIMUM_BLOCK_RESERVED_WEIGHT, MAX_BLOCK_WEIGHT);
85+ const size_t reserved_weight{options.block_reserved_weight .value_or (DEFAULT_BLOCK_RESERVED_WEIGHT)};
86+ // Reject too-small values instead of clamping so callers don't silently
87+ // end up mining with different options than requested.
88+ if (reserved_weight < MINIMUM_BLOCK_RESERVED_WEIGHT) {
89+ throw std::runtime_error (strprintf (" block_reserved_weight (%zu) must be at least %u weight units" ,
90+ reserved_weight,
91+ MINIMUM_BLOCK_RESERVED_WEIGHT));
92+ }
93+ options.block_reserved_weight = std::min<size_t >(reserved_weight, MAX_BLOCK_WEIGHT);
8594 options.coinbase_output_max_additional_sigops = std::clamp<size_t >(options.coinbase_output_max_additional_sigops , 0 , MAX_BLOCK_SIGOPS_COST);
8695 // Limit weight to between block_reserved_weight and MAX_BLOCK_WEIGHT for sanity:
8796 // block_reserved_weight can safely exceed -blockmaxweight, but the rest of the block template will be empty.
You can’t perform that action at this time.
0 commit comments