2020-04-16 13:14:08 -04:00
|
|
|
// Copyright (c) 2018-2020 The Bitcoin Core developers
|
2018-06-29 10:10:01 -04: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 12:40:50 -03:00
|
|
|
#include <rpc/util.h>
|
2018-06-29 10:10:01 -04:00
|
|
|
#include <zmq/zmqabstractnotifier.h>
|
|
|
|
#include <zmq/zmqnotificationinterface.h>
|
|
|
|
|
|
|
|
#include <univalue.h>
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
2020-08-14 05:30:55 -04:00
|
|
|
static RPCHelpMan getzmqnotifications()
|
2018-06-29 10:10:01 -04:00
|
|
|
{
|
2020-08-14 05:30:55 -04:00
|
|
|
return RPCHelpMan{"getzmqnotifications",
|
2018-12-21 14:29:36 -03:00
|
|
|
"\nReturns information about the active ZeroMQ notifications.\n",
|
|
|
|
{},
|
|
|
|
RPCResult{
|
2020-01-09 14:00:57 -03: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 14:29:36 -03:00
|
|
|
},
|
|
|
|
RPCExamples{
|
|
|
|
HelpExampleCli("getzmqnotifications", "")
|
2018-06-29 10:10:01 -04:00
|
|
|
+ HelpExampleRpc("getzmqnotifications", "")
|
2018-12-21 14:29:36 -03:00
|
|
|
},
|
2020-08-14 05:30:55 -04:00
|
|
|
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
|
|
|
|
{
|
2018-06-29 10:10:01 -04: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 21:42:03 -03:00
|
|
|
obj.pushKV("hwm", n->GetOutboundMessageHighWaterMark());
|
2018-06-29 10:10:01 -04:00
|
|
|
result.push_back(obj);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
2020-08-14 05:30:55 -04:00
|
|
|
},
|
|
|
|
};
|
2018-06-29 10:10:01 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
const CRPCCommand commands[] =
|
2021-01-12 02:41:46 -03:00
|
|
|
{ // category actor (function)
|
|
|
|
// ----------------- -----------------------
|
|
|
|
{ "zmq", &getzmqnotifications, },
|
2018-06-29 10:10:01 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
} // anonymous namespace
|
|
|
|
|
|
|
|
void RegisterZMQRPCCommands(CRPCTable& t)
|
|
|
|
{
|
|
|
|
for (const auto& c : commands) {
|
|
|
|
t.appendCommand(c.name, &c);
|
|
|
|
}
|
|
|
|
}
|