Skip to content

Commit 7392b8b

Browse files
committed
miner: clamp options instead of asserting
1 parent f5f853d commit 7392b8b

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/node/miner.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,8 @@ void RegenerateCommitments(CBlock& block, ChainstateManager& chainman)
7777

7878
static BlockAssembler::Options ClampOptions(BlockAssembler::Options options)
7979
{
80-
Assert(options.block_reserved_weight <= MAX_BLOCK_WEIGHT);
81-
Assert(options.block_reserved_weight >= MINIMUM_BLOCK_RESERVED_WEIGHT);
82-
Assert(options.coinbase_output_max_additional_sigops <= MAX_BLOCK_SIGOPS_COST);
80+
options.block_reserved_weight = std::clamp<size_t>(options.block_reserved_weight, MINIMUM_BLOCK_RESERVED_WEIGHT, MAX_BLOCK_WEIGHT);
81+
options.coinbase_output_max_additional_sigops = std::clamp<size_t>(options.coinbase_output_max_additional_sigops, 0, MAX_BLOCK_SIGOPS_COST);
8382
// Limit weight to between block_reserved_weight and MAX_BLOCK_WEIGHT for sanity:
8483
// block_reserved_weight can safely exceed -blockmaxweight, but the rest of the block template will be empty.
8584
options.nBlockMaxWeight = std::clamp<size_t>(options.nBlockMaxWeight, options.block_reserved_weight, MAX_BLOCK_WEIGHT);

0 commit comments

Comments
 (0)