Bitcoin ABC 0.26.3
P2P Digital Currency
Loading...
Searching...
No Matches
zmqrpc.cpp
Go to the documentation of this file.
1// Copyright (c) 2018 The Bitcoin Core developers
2// Distributed under the MIT software license, see the accompanying
3// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
5#include <zmq/zmqrpc.h>
6
7#include <rpc/server.h>
8#include <rpc/util.h>
11
12#include <univalue.h>
13
14namespace {
15
17 return RPCHelpMan{
18 "getzmqnotifications",
19 "Returns information about the active ZeroMQ notifications.\n",
20 {},
23 "",
24 "",
25 {
27 "",
28 "",
29 {
30 {RPCResult::Type::STR, "type", "Type of notification"},
31 {RPCResult::Type::STR, "address",
32 "Address of the publisher"},
34 "Outbound message high water mark"},
35 }},
36 }},
37 RPCExamples{HelpExampleCli("getzmqnotifications", "") +
38 HelpExampleRpc("getzmqnotifications", "")},
39 [&](const RPCHelpMan &self, const Config &config,
40 const JSONRPCRequest &request) -> UniValue {
42 if (g_zmq_notification_interface != nullptr) {
43 for (const auto *n :
44 g_zmq_notification_interface->GetActiveNotifiers()) {
46 obj.pushKV("type", n->GetType());
47 obj.pushKV("address", n->GetAddress());
48 obj.pushKV("hwm", n->GetOutboundMessageHighWaterMark());
49 result.push_back(obj);
50 }
51 }
52
53 return result;
54 },
55 };
56}
57
58// clang-format off
59static const CRPCCommand commands[] = {
60 // category actor (function)
61 // ----------------- -----------------------
62 { "zmq", getzmqnotifications, },
63};
64// clang-format on
65
66} // anonymous namespace
67
69 for (const auto &c : commands) {
70 t.appendCommand(c.name, &c);
71 }
72}
RPC command dispatcher.
Definition server.h:194
T GetRand(T nMax=std::numeric_limits< T >::max()) noexcept
Generate a uniform random integer of type T in the range [0..nMax) nMax defaults to std::numeric_limi...
Definition random.h:85
std::string HelpExampleCli(const std::string &methodname, const std::string &args)
Definition util.cpp:150
std::string HelpExampleRpc(const std::string &methodname, const std::string &args)
Definition util.cpp:167
std::unique_ptr< CZMQNotificationInterface > g_zmq_notification_interface
void RegisterZMQRPCCommands(CRPCTable &t)
Definition zmqrpc.cpp:68