Bitcoin ABC  0.22.13
P2P Digital Currency
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 
14 namespace {
15 
16 UniValue getzmqnotifications(const Config &config,
17  const JSONRPCRequest &request) {
18  RPCHelpMan{
19  "getzmqnotifications",
20  "Returns information about the active ZeroMQ notifications.\n",
21  {},
22  RPCResult{
24  "",
25  "",
26  {
28  "",
29  "",
30  {
31  {RPCResult::Type::STR, "type", "Type of notification"},
32  {RPCResult::Type::STR, "address",
33  "Address of the publisher"},
34  {RPCResult::Type::NUM, "hwm",
35  "Outbound message high water mark"},
36  }},
37  }},
38  RPCExamples{HelpExampleCli("getzmqnotifications", "") +
39  HelpExampleRpc("getzmqnotifications", "")},
40  }
41  .Check(request);
42 
43  UniValue result(UniValue::VARR);
44  if (g_zmq_notification_interface != nullptr) {
45  for (const auto *n :
48  obj.pushKV("type", n->GetType());
49  obj.pushKV("address", n->GetAddress());
50  obj.pushKV("hwm", n->GetOutboundMessageHighWaterMark());
51  result.push_back(obj);
52  }
53  }
54 
55  return result;
56 }
57 
58 // clang-format off
59 static const CRPCCommand commands[] = {
60  // category name actor (function) argNames
61  // ----------------- ------------------------ ----------------------- ----------
62  { "zmq", "getzmqnotifications", 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 }
Bitcoin RPC command dispatcher.
Definition: server.h:198
bool appendCommand(const std::string &name, const CRPCCommand *pcmd)
Appends a CRPCCommand to the dispatch table.
Definition: server.cpp:316
std::string HelpExampleRpc(const std::string &methodname, const std::string &args)
Definition: util.cpp:143
Definition: config.h:19
std::string HelpExampleCli(const std::string &methodname, const std::string &args)
Definition: util.cpp:138
void RegisterZMQRPCCommands(CRPCTable &t)
Definition: zmqrpc.cpp:68
std::list< const CZMQAbstractNotifier * > GetActiveNotifiers() const
CZMQNotificationInterface * g_zmq_notification_interface