Bitcoin ABC  0.24.11
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 static RPCHelpMan getzmqnotifications() {
17  return RPCHelpMan{
18  "getzmqnotifications",
19  "Returns information about the active ZeroMQ notifications.\n",
20  {},
21  RPCResult{
23  "",
24  "",
25  {
27  "",
28  "",
29  {
30  {RPCResult::Type::STR, "type", "Type of notification"},
31  {RPCResult::Type::STR, "address",
32  "Address of the publisher"},
33  {RPCResult::Type::NUM, "hwm",
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 {
41  UniValue result(UniValue::VARR);
42  if (g_zmq_notification_interface != nullptr) {
43  for (const auto *n :
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
59 static 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 }
zmqabstractnotifier.h
HelpExampleCli
std::string HelpExampleCli(const std::string &methodname, const std::string &args)
Definition: util.cpp:157
UniValue::VOBJ
@ VOBJ
Definition: univalue.h:27
RPCHelpMan
Definition: util.h:334
zmqrpc.h
RPCResult::Type::NUM
@ NUM
UniValue
Definition: univalue.h:23
Config
Definition: config.h:17
RPCResult::Type::OBJ
@ OBJ
CRPCCommand
Definition: server.h:147
g_zmq_notification_interface
CZMQNotificationInterface * g_zmq_notification_interface
Definition: zmqnotificationinterface.cpp:207
univalue.h
RegisterZMQRPCCommands
void RegisterZMQRPCCommands(CRPCTable &t)
Definition: zmqrpc.cpp:68
RPCExamples
Definition: util.h:326
RPCResult::Type::STR
@ STR
RPCResult::Type::ARR
@ ARR
zmqnotificationinterface.h
HelpExampleRpc
std::string HelpExampleRpc(const std::string &methodname, const std::string &args)
Definition: util.cpp:162
CZMQNotificationInterface::GetActiveNotifiers
std::list< const CZMQAbstractNotifier * > GetActiveNotifiers() const
Definition: zmqnotificationinterface.cpp:21
CRPCTable
RPC command dispatcher.
Definition: server.h:184
CRPCTable::appendCommand
void appendCommand(const std::string &name, const CRPCCommand *pcmd)
Appends a CRPCCommand to the dispatch table.
Definition: server.cpp:322
JSONRPCRequest
Definition: request.h:33
util.h
RPCResult
Definition: util.h:247
UniValue::VARR
@ VARR
Definition: univalue.h:27
server.h