diff --git a/src/rpc/abc.cpp b/src/rpc/abc.cpp index 509714a44..3f45e5588 100644 --- a/src/rpc/abc.cpp +++ b/src/rpc/abc.cpp @@ -1,89 +1,94 @@ // Copyright (c) 2017-2020 The Bitcoin developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include #include #include #include #include #include static UniValue getexcessiveblock(const Config &config, const JSONRPCRequest &request) { if (request.fHelp || request.params.size() != 0) { throw std::runtime_error( "getexcessiveblock\n" "\nReturn the excessive block size." "\nResult\n" " excessiveBlockSize (integer) block size in bytes\n" "\nExamples:\n" + HelpExampleCli("getexcessiveblock", "") + HelpExampleRpc("getexcessiveblock", "")); } UniValue ret(UniValue::VOBJ); ret.pushKV("excessiveBlockSize", config.GetMaxBlockSize()); return ret; } static UniValue setexcessiveblock(Config &config, const JSONRPCRequest &request) { if (request.fHelp || request.params.size() != 1) { throw std::runtime_error( "setexcessiveblock blockSize\n" "\nSet the excessive block size. Excessive blocks will not be used " - "in the active chain or relayed. This discourages the propagation " + "in the active chain or relayed. This discourages the propagation " "of blocks that you consider excessively large." + "\nArguments\n" + "1. blockSize (integer, required) Excessive block size in bytes. " + "Must be greater than " + + std::to_string(LEGACY_MAX_BLOCK_SIZE) + + ".\n" "\nResult\n" " blockSize (integer) excessive block size in bytes\n" "\nExamples:\n" + - HelpExampleCli("setexcessiveblock", "") + - HelpExampleRpc("setexcessiveblock", "")); + HelpExampleCli("setexcessiveblock", "25000000") + + HelpExampleRpc("setexcessiveblock", "25000000")); } int64_t ebs = 0; if (request.params[0].isNum()) { ebs = request.params[0].get_int64(); } else if (!ParseInt64(request.params[0].get_str(), &ebs)) { throw JSONRPCError( RPC_INVALID_PARAMETER, std::string( "Invalid parameter, excessiveblock must be an integer")); } // Do not allow maxBlockSize to be set below historic 1MB limit if (ebs <= int64_t(LEGACY_MAX_BLOCK_SIZE)) { throw JSONRPCError( RPC_INVALID_PARAMETER, std::string( "Invalid parameter, excessiveblock must be larger than ") + std::to_string(LEGACY_MAX_BLOCK_SIZE)); } // Set the new max block size. if (!config.SetMaxBlockSize(ebs)) { throw JSONRPCError(RPC_INVALID_PARAMETER, "Unexpected error"); } // settingsToUserAgentString(); std::ostringstream ret; ret << "Excessive Block set to " << ebs << " bytes."; return UniValue(ret.str()); } // clang-format off static const ContextFreeRPCCommand commands[] = { // category name actor (function) argNames // ------------------- ------------------------ ---------------------- ---------- { "network", "getexcessiveblock", getexcessiveblock, {}}, { "network", "setexcessiveblock", setexcessiveblock, {"maxBlockSize"}}, }; // clang-format on void RegisterABCRPCCommands(CRPCTable &t) { for (unsigned int vcidx = 0; vcidx < ARRAYLEN(commands); vcidx++) { t.appendCommand(commands[vcidx].name, &commands[vcidx]); } }