Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/abc.cpp
// Copyright (c) 2017-2020 The Bitcoin developers | // Copyright (c) 2017-2020 The Bitcoin developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#include <config.h> | #include <config.h> | ||||
#include <consensus/consensus.h> | #include <consensus/consensus.h> | ||||
#include <rpc/server.h> | #include <rpc/server.h> | ||||
#include <rpc/util.h> | #include <rpc/util.h> | ||||
#include <sync.h> | #include <sync.h> | ||||
#include <util/strencodings.h> | #include <util/strencodings.h> | ||||
#include <util/string.h> | |||||
#include <validation.h> | #include <validation.h> | ||||
#include <univalue.h> | #include <univalue.h> | ||||
static UniValue getexcessiveblock(const Config &config, | static UniValue getexcessiveblock(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"getexcessiveblock", | "getexcessiveblock", | ||||
Show All 15 Lines | static UniValue setexcessiveblock(Config &config, | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"setexcessiveblock", | "setexcessiveblock", | ||||
"Set the excessive block size. Excessive blocks will not be used in " | "Set the excessive block size. Excessive blocks will not be used in " | ||||
"the active chain or relayed. This discourages the propagation of " | "the active chain or relayed. This discourages the propagation of " | ||||
"blocks that you consider excessively large.", | "blocks that you consider excessively large.", | ||||
{ | { | ||||
{"blockSize", RPCArg::Type::NUM, RPCArg::Optional::NO, | {"blockSize", RPCArg::Type::NUM, RPCArg::Optional::NO, | ||||
"Excessive block size in bytes. Must be greater than " + | "Excessive block size in bytes. Must be greater than " + | ||||
std::to_string(LEGACY_MAX_BLOCK_SIZE) + "."}, | ToString(LEGACY_MAX_BLOCK_SIZE) + "."}, | ||||
}, | }, | ||||
RPCResult{RPCResult::Type::NUM, "", "excessive block size in bytes"}, | RPCResult{RPCResult::Type::NUM, "", "excessive block size in bytes"}, | ||||
RPCExamples{HelpExampleCli("setexcessiveblock", "25000000") + | RPCExamples{HelpExampleCli("setexcessiveblock", "25000000") + | ||||
HelpExampleRpc("setexcessiveblock", "25000000")}, | HelpExampleRpc("setexcessiveblock", "25000000")}, | ||||
} | } | ||||
.Check(request); | .Check(request); | ||||
if (!request.params[0].isNum()) { | if (!request.params[0].isNum()) { | ||||
throw JSONRPCError( | throw JSONRPCError( | ||||
RPC_INVALID_PARAMETER, | RPC_INVALID_PARAMETER, | ||||
std::string( | std::string( | ||||
"Invalid parameter, excessiveblock must be an integer")); | "Invalid parameter, excessiveblock must be an integer")); | ||||
} | } | ||||
int64_t ebs = request.params[0].get_int64(); | int64_t ebs = request.params[0].get_int64(); | ||||
// Do not allow maxBlockSize to be set below historic 1MB limit | // Do not allow maxBlockSize to be set below historic 1MB limit | ||||
if (ebs <= int64_t(LEGACY_MAX_BLOCK_SIZE)) { | if (ebs <= int64_t(LEGACY_MAX_BLOCK_SIZE)) { | ||||
throw JSONRPCError( | throw JSONRPCError( | ||||
RPC_INVALID_PARAMETER, | RPC_INVALID_PARAMETER, | ||||
std::string( | std::string( | ||||
"Invalid parameter, excessiveblock must be larger than ") + | "Invalid parameter, excessiveblock must be larger than ") + | ||||
std::to_string(LEGACY_MAX_BLOCK_SIZE)); | ToString(LEGACY_MAX_BLOCK_SIZE)); | ||||
} | } | ||||
// Set the new max block size. | // Set the new max block size. | ||||
{ | { | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
if (!config.SetMaxBlockSize(ebs)) { | if (!config.SetMaxBlockSize(ebs)) { | ||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "Unexpected error"); | throw JSONRPCError(RPC_INVALID_PARAMETER, "Unexpected error"); | ||||
} | } | ||||
Show All 22 Lines |