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 <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) { | ||||
if (request.fHelp || request.params.size() != 0) { | RPCHelpMan{ | ||||
throw std::runtime_error(RPCHelpMan{ | |||||
"getexcessiveblock", | "getexcessiveblock", | ||||
"\nReturn the excessive block size.", | "\nReturn the excessive block size.", | ||||
{}, | {}, | ||||
RPCResult{" excessiveBlockSize (integer) block size in bytes\n"}, | RPCResult{" excessiveBlockSize (integer) block size in bytes\n"}, | ||||
RPCExamples{HelpExampleCli("getexcessiveblock", "") + | RPCExamples{HelpExampleCli("getexcessiveblock", "") + | ||||
HelpExampleRpc("getexcessiveblock", "")}, | HelpExampleRpc("getexcessiveblock", "")}, | ||||
} | } | ||||
.ToString()); | .Check(request); | ||||
} | |||||
UniValue ret(UniValue::VOBJ); | UniValue ret(UniValue::VOBJ); | ||||
ret.pushKV("excessiveBlockSize", config.GetMaxBlockSize()); | ret.pushKV("excessiveBlockSize", config.GetMaxBlockSize()); | ||||
return ret; | return ret; | ||||
} | } | ||||
static UniValue setexcessiveblock(Config &config, | static UniValue setexcessiveblock(Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
if (request.fHelp || request.params.size() != 1) { | RPCHelpMan{ | ||||
throw std::runtime_error(RPCHelpMan{ | |||||
"setexcessiveblock", | "setexcessiveblock", | ||||
"\nSet the excessive block size. Excessive blocks will not be used " | "\nSet the excessive block size. Excessive blocks will not be used in " | ||||
"in the active chain or relayed. This discourages the propagation " | "the active chain or relayed. This discourages the propagation of " | ||||
"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) + "."}, | std::to_string(LEGACY_MAX_BLOCK_SIZE) + "."}, | ||||
}, | }, | ||||
RPCResult{" blockSize (integer) excessive block size in bytes\n"}, | RPCResult{" blockSize (integer) excessive block size in bytes\n"}, | ||||
RPCExamples{HelpExampleCli("setexcessiveblock", "25000000") + | RPCExamples{HelpExampleCli("setexcessiveblock", "25000000") + | ||||
HelpExampleRpc("setexcessiveblock", "25000000")}, | HelpExampleRpc("setexcessiveblock", "25000000")}, | ||||
} | } | ||||
.ToString()); | .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")); | ||||
} | } | ||||
Show All 39 Lines |