Bitcoin Core
22.99.0
P2P Digital Currency
src
zmq
zmqrpc.cpp
Go to the documentation of this file.
1
// Copyright (c) 2018-2021 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>
9
#include <
zmq/zmqabstractnotifier.h
>
10
#include <
zmq/zmqnotificationinterface.h
>
11
12
#include <
univalue.h
>
13
14
namespace
{
15
16
static
RPCHelpMan
getzmqnotifications()
17
{
18
return
RPCHelpMan
{
"getzmqnotifications"
,
19
"\nReturns information about the active ZeroMQ notifications.\n"
,
20
{},
21
RPCResult
{
22
RPCResult::Type::ARR
,
""
,
""
,
23
{
24
{
RPCResult::Type::OBJ
,
""
,
""
,
25
{
26
{
RPCResult::Type::STR
,
"type"
,
"Type of notification"
},
27
{
RPCResult::Type::STR
,
"address"
,
"Address of the publisher"
},
28
{
RPCResult::Type::NUM
,
"hwm"
,
"Outbound message high water mark"
},
29
}},
30
}
31
},
32
RPCExamples
{
33
HelpExampleCli
(
"getzmqnotifications"
,
""
)
34
+
HelpExampleRpc
(
"getzmqnotifications"
,
""
)
35
},
36
[&](
const
RPCHelpMan
&
self
,
const
JSONRPCRequest
& request) ->
UniValue
37
{
38
UniValue
result(
UniValue::VARR
);
39
if
(
g_zmq_notification_interface
!=
nullptr
) {
40
for
(
const
auto
* n :
g_zmq_notification_interface
->
GetActiveNotifiers
()) {
41
UniValue
obj(
UniValue::VOBJ
);
42
obj.pushKV(
"type"
, n->GetType());
43
obj.pushKV(
"address"
, n->GetAddress());
44
obj.pushKV(
"hwm"
, n->GetOutboundMessageHighWaterMark());
45
result.push_back(obj);
46
}
47
}
48
49
return
result;
50
},
51
};
52
}
53
54
const
CRPCCommand
commands[] =
55
{
// category actor (function)
56
// ----------------- -----------------------
57
{
"zmq"
, &getzmqnotifications, },
58
};
59
60
}
// anonymous namespace
61
62
void
RegisterZMQRPCCommands
(
CRPCTable
& t)
63
{
64
for
(
const
auto
& c : commands) {
65
t
.appendCommand(c.name, &c);
66
}
67
}
zmqabstractnotifier.h
HelpExampleCli
std::string HelpExampleCli(const std::string &methodname, const std::string &args)
Definition:
util.cpp:156
UniValue::VOBJ
@ VOBJ
Definition:
univalue.h:19
RPCHelpMan
Definition:
util.h:346
zmqrpc.h
RPCResult::Type::NUM
@ NUM
UniValue
Definition:
univalue.h:17
RPCResult::Type::OBJ
@ OBJ
CRPCCommand
Definition:
server.h:89
g_zmq_notification_interface
CZMQNotificationInterface * g_zmq_notification_interface
Definition:
zmqnotificationinterface.cpp:191
univalue.h
RegisterZMQRPCCommands
void RegisterZMQRPCCommands(CRPCTable &t)
Definition:
zmqrpc.cpp:62
RPCExamples
Definition:
util.h:336
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:174
CZMQNotificationInterface::GetActiveNotifiers
std::list< const CZMQAbstractNotifier * > GetActiveNotifiers() const
Definition:
zmqnotificationinterface.cpp:23
CRPCTable
RPC command dispatcher.
Definition:
server.h:125
JSONRPCRequest
Definition:
request.h:28
RPCResult
Definition:
util.h:231
UniValue::VARR
@ VARR
Definition:
univalue.h:19
server.h
ByteUnit::t
@ t
Generated on Fri Feb 18 2022 20:03:56 for Bitcoin Core by
1.8.17