2019-12-30 22:39:22 +13:00
|
|
|
// Copyright (c) 2018-2019 The Bitcoin Core developers
|
2018-06-29 16:10:01 +02:00
|
|
|
// Distributed under the MIT software license, see the accompanying
|
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
|
|
|
|
#include <zmq/zmqrpc.h>
|
|
|
|
|
|
|
|
#include <rpc/server.h>
|
2018-11-06 10:40:50 -05:00
|
|
|
#include <rpc/util.h>
|
2018-06-29 16:10:01 +02:00
|
|
|
#include <zmq/zmqabstractnotifier.h>
|
|
|
|
#include <zmq/zmqnotificationinterface.h>
|
|
|
|
|
|
|
|
#include <univalue.h>
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
UniValue getzmqnotifications(const JSONRPCRequest& request)
|
|
|
|
{
|
2018-10-20 08:19:44 -04:00
|
|
|
RPCHelpMan{"getzmqnotifications",
|
2018-12-21 12:29:36 -05:00
|
|
|
"\nReturns information about the active ZeroMQ notifications.\n",
|
|
|
|
{},
|
|
|
|
RPCResult{
|
2020-01-10 00:00:57 +07:00
|
|
|
RPCResult::Type::ARR, "", "",
|
|
|
|
{
|
|
|
|
{RPCResult::Type::OBJ, "", "",
|
|
|
|
{
|
|
|
|
{RPCResult::Type::STR, "type", "Type of notification"},
|
|
|
|
{RPCResult::Type::STR, "address", "Address of the publisher"},
|
|
|
|
{RPCResult::Type::NUM, "hwm", "Outbound message high water mark"},
|
|
|
|
}},
|
|
|
|
}
|
2018-12-21 12:29:36 -05:00
|
|
|
},
|
|
|
|
RPCExamples{
|
|
|
|
HelpExampleCli("getzmqnotifications", "")
|
2018-06-29 16:10:01 +02:00
|
|
|
+ HelpExampleRpc("getzmqnotifications", "")
|
2018-12-21 12:29:36 -05:00
|
|
|
},
|
2019-06-19 13:59:11 +09:00
|
|
|
}.Check(request);
|
2018-06-29 16:10:01 +02:00
|
|
|
|
|
|
|
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());
|
2018-08-24 20:42:03 -04:00
|
|
|
obj.pushKV("hwm", n->GetOutboundMessageHighWaterMark());
|
2018-06-29 16:10:01 +02:00
|
|
|
result.push_back(obj);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
const CRPCCommand commands[] =
|
|
|
|
{ // category name actor (function) argNames
|
|
|
|
// ----------------- ------------------------ ----------------------- ----------
|
|
|
|
{ "zmq", "getzmqnotifications", &getzmqnotifications, {} },
|
|
|
|
};
|
|
|
|
|
|
|
|
} // anonymous namespace
|
|
|
|
|
|
|
|
void RegisterZMQRPCCommands(CRPCTable& t)
|
|
|
|
{
|
|
|
|
for (const auto& c : commands) {
|
|
|
|
t.appendCommand(c.name, &c);
|
|
|
|
}
|
|
|
|
}
|