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 <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) { | if (request.fHelp || request.params.size() != 0) { | ||||
throw std::runtime_error( | throw std::runtime_error(RPCHelpMan{ | ||||
RPCHelpMan{ | "getexcessiveblock", | ||||
"getexcessiveblock", "\nReturn the excessive block size.", {}} | "\nReturn the excessive block size.", | ||||
.ToString() + | {}, | ||||
"\nResult\n" | RPCResult{" excessiveBlockSize (integer) block size in bytes\n"}, | ||||
" excessiveBlockSize (integer) block size in bytes\n" | RPCExamples{HelpExampleCli("getexcessiveblock", "") + | ||||
"\nExamples:\n" + | HelpExampleRpc("getexcessiveblock", "")}, | ||||
HelpExampleCli("getexcessiveblock", "") + | } | ||||
HelpExampleRpc("getexcessiveblock", "")); | .ToString()); | ||||
} | } | ||||
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) { | if (request.fHelp || request.params.size() != 1) { | ||||
throw std::runtime_error( | throw std::runtime_error(RPCHelpMan{ | ||||
RPCHelpMan{ | |||||
"setexcessiveblock", | "setexcessiveblock", | ||||
"\nSet the excessive block size. Excessive blocks will not be " | "\nSet the excessive block size. Excessive blocks will not be " | ||||
"used in the active chain or relayed. This discourages the " | "used in the active chain or relayed. This discourages the " | ||||
"propagation of blocks that you consider excessively large.", | "propagation of blocks that you consider excessively large.", | ||||
{ | { | ||||
{"blockSize", RPCArg::Type::NUM, /* opt */ false, | {"blockSize", RPCArg::Type::NUM, /* opt */ false, | ||||
/* default_value */ "", | /* default_value */ "", | ||||
"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) + "."}, | ||||
}} | }, | ||||
.ToString() + | RPCResult{" blockSize (integer) excessive block size in bytes\n"}, | ||||
"\nResult\n" | RPCExamples{HelpExampleCli("setexcessiveblock", "25000000") + | ||||
" blockSize (integer) excessive block size in bytes\n" | HelpExampleRpc("setexcessiveblock", "25000000")}, | ||||
"\nExamples:\n" + | } | ||||
HelpExampleCli("setexcessiveblock", "25000000") + | .ToString()); | ||||
HelpExampleRpc("setexcessiveblock", "25000000")); | |||||
} | } | ||||
int64_t ebs = 0; | int64_t ebs = 0; | ||||
if (request.params[0].isNum()) { | if (request.params[0].isNum()) { | ||||
ebs = request.params[0].get_int64(); | ebs = request.params[0].get_int64(); | ||||
} else if (!ParseInt64(request.params[0].get_str(), &ebs)) { | } else if (!ParseInt64(request.params[0].get_str(), &ebs)) { | ||||
throw JSONRPCError( | throw JSONRPCError( | ||||
RPC_INVALID_PARAMETER, | RPC_INVALID_PARAMETER, | ||||
Show All 38 Lines |