mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-03-03 19:49:12 +01:00
mining: enforce minimum reserved weight for IPC
Previously a lower value was silently clamped to MINIMUM_BLOCK_RESERVED_WEIGHT.
This commit is contained in:
@@ -67,6 +67,7 @@
|
||||
#include <any>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <stdexcept>
|
||||
#include <utility>
|
||||
|
||||
#include <boost/signals2/signal.hpp>
|
||||
@@ -969,6 +970,16 @@ public:
|
||||
|
||||
std::unique_ptr<BlockTemplate> createNewBlock(const BlockCreateOptions& options) override
|
||||
{
|
||||
// Reject too-small values instead of clamping so callers don't silently
|
||||
// end up mining with different options than requested. This matches the
|
||||
// behavior of the `-blockreservedweight` startup option, which rejects
|
||||
// values below MINIMUM_BLOCK_RESERVED_WEIGHT.
|
||||
if (options.block_reserved_weight && options.block_reserved_weight < MINIMUM_BLOCK_RESERVED_WEIGHT) {
|
||||
throw std::runtime_error(strprintf("block_reserved_weight (%zu) must be at least %u weight units",
|
||||
*options.block_reserved_weight,
|
||||
MINIMUM_BLOCK_RESERVED_WEIGHT));
|
||||
}
|
||||
|
||||
// Ensure m_tip_block is set so consumers of BlockTemplate can rely on that.
|
||||
if (!waitTipChanged(uint256::ZERO, MillisecondsDouble::max())) return {};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user