| 28 | namespace node { |
| 29 | |
| 30 | Result<void> CheckMiningOptions(BlockCreateOptions options, bool use_argnames) |
| 31 | { |
| 32 | options = FlattenMiningOptions(std::move(options)); |
| 33 | if (*options.block_reserved_weight < MINIMUM_BLOCK_RESERVED_WEIGHT) { |
| 34 | return Error{Untranslated(strprintf("%s (%d) is lower than minimum safety value of (%d)", |
| 35 | use_argnames ? "-blockreservedweight" : "block_reserved_weight", |
| 36 | *options.block_reserved_weight, MINIMUM_BLOCK_RESERVED_WEIGHT))}; |
| 37 | } |
| 38 | if (*options.block_reserved_weight > MAX_BLOCK_WEIGHT) { |
| 39 | return Error{Untranslated(strprintf("%s (%d) exceeds consensus maximum block weight (%d)", |
| 40 | use_argnames ? "-blockreservedweight" : "block_reserved_weight", |
| 41 | *options.block_reserved_weight, MAX_BLOCK_WEIGHT))}; |
| 42 | } |
| 43 | if (*options.block_max_weight > MAX_BLOCK_WEIGHT) { |
| 44 | return Error{Untranslated(strprintf("%s (%d) exceeds consensus maximum block weight (%d)", |
| 45 | use_argnames ? "-blockmaxweight" : "block_max_weight", |
| 46 | *options.block_max_weight, MAX_BLOCK_WEIGHT))}; |
| 47 | } |
| 48 | if (*options.block_reserved_weight > *options.block_max_weight) { |
| 49 | return Error{Untranslated(strprintf("%s (%d) exceeds %s (%d)", |
| 50 | use_argnames ? "-blockreservedweight" : "block_reserved_weight", |
| 51 | *options.block_reserved_weight, |
| 52 | use_argnames ? "-blockmaxweight" : "block_max_weight", |
| 53 | *options.block_max_weight))}; |
| 54 | } |
| 55 | if (options.coinbase_output_max_additional_sigops > MAX_BLOCK_SIGOPS_COST) { |
| 56 | return Error{Untranslated(strprintf("%s (%zu) exceeds consensus maximum block sigops cost (%d)", |
| 57 | "coinbase_output_max_additional_sigops", |
| 58 | options.coinbase_output_max_additional_sigops, MAX_BLOCK_SIGOPS_COST))}; |
| 59 | } |
| 60 | return {}; |
| 61 | } |
| 62 | |
| 63 | Result<BlockCreateOptions> ReadMiningArgs(const ArgsManager& args) |
| 64 | { |
no test coverage detected