diff --git a/src/zmq/zmqrpc.cpp b/src/zmq/zmqrpc.cpp index ea1954cc6..58691ff23 100644 --- a/src/zmq/zmqrpc.cpp +++ b/src/zmq/zmqrpc.cpp @@ -1,70 +1,66 @@ // Copyright (c) 2018 The Bitcoin Core 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 namespace { UniValue getzmqnotifications(const Config &config, const JSONRPCRequest &request) { - if (request.fHelp || request.params.size() != 0) { - throw std::runtime_error(RPCHelpMan{ - "getzmqnotifications", - "\nReturns information about the active ZeroMQ " - "notifications.\n", - {}, - RPCResult{ - "[\n" - " { (json object)\n" - " \"type\": \"pubhashtx\", (string) Type of notification\n" - " \"address\": \"...\" (string) Address of the " - "publisher\n" - " \"hwm\": n (numeric) Outbound message high " - "water mark\n" - " },\n" - " ...\n" - "]\n"}, - RPCExamples{HelpExampleCli("getzmqnotifications", "") + - HelpExampleRpc("getzmqnotifications", "")}, - } - .ToString()); + RPCHelpMan{ + "getzmqnotifications", + "\nReturns information about the active ZeroMQ notifications.\n", + {}, + RPCResult{ + "[\n" + " { (json object)\n" + " \"type\": \"pubhashtx\", (string) Type of notification\n" + " \"address\": \"...\" (string) Address of the publisher\n" + " \"hwm\": n (numeric) Outbound message high " + "water mark\n" + " },\n" + " ...\n" + "]\n"}, + RPCExamples{HelpExampleCli("getzmqnotifications", "") + + HelpExampleRpc("getzmqnotifications", "")}, } + .Check(request); UniValue result(UniValue::VARR); if (g_zmq_notification_interface != nullptr) { for (const auto *n : g_zmq_notification_interface->GetActiveNotifiers()) { UniValue obj(UniValue::VOBJ); obj.pushKV("type", n->GetType()); obj.pushKV("address", n->GetAddress()); obj.pushKV("hwm", n->GetOutboundMessageHighWaterMark()); result.push_back(obj); } } return result; } // clang-format off static const CRPCCommand commands[] = { // category name actor (function) argNames // ----------------- ------------------------ ----------------------- ---------- { "zmq", "getzmqnotifications", getzmqnotifications, {} }, }; // clang-format on } // anonymous namespace void RegisterZMQRPCCommands(CRPCTable &t) { for (const auto &c : commands) { t.appendCommand(c.name, &c); } }