diff --git a/src/node/miner.cpp b/src/node/miner.cpp index 02a7684178c..a08c70e29da 100644 --- a/src/node/miner.cpp +++ b/src/node/miner.cpp @@ -77,9 +77,8 @@ void RegenerateCommitments(CBlock& block, ChainstateManager& chainman) static BlockAssembler::Options ClampOptions(BlockAssembler::Options options) { - Assert(options.block_reserved_weight <= MAX_BLOCK_WEIGHT); - Assert(options.block_reserved_weight >= MINIMUM_BLOCK_RESERVED_WEIGHT); - Assert(options.coinbase_output_max_additional_sigops <= MAX_BLOCK_SIGOPS_COST); + options.block_reserved_weight = std::clamp(options.block_reserved_weight, MINIMUM_BLOCK_RESERVED_WEIGHT, MAX_BLOCK_WEIGHT); + options.coinbase_output_max_additional_sigops = std::clamp(options.coinbase_output_max_additional_sigops, 0, MAX_BLOCK_SIGOPS_COST); // Limit weight to between block_reserved_weight and MAX_BLOCK_WEIGHT for sanity: // block_reserved_weight can safely exceed -blockmaxweight, but the rest of the block template will be empty. options.nBlockMaxWeight = std::clamp(options.nBlockMaxWeight, options.block_reserved_weight, MAX_BLOCK_WEIGHT);