Bitcoin Core
31.1.0
P2P Digital Currency
Toggle main menu visibility
Loading...
Searching...
No Matches
src
zmq
zmqrpc.cpp
Go to the documentation of this file.
1
// Copyright (c) 2018-present 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 <
univalue.h
>
10
#include <
zmq/zmqabstractnotifier.h
>
11
#include <
zmq/zmqnotificationinterface.h
>
12
13
#include <list>
14
#include <memory>
15
#include <string>
16
#include <utility>
17
#include <vector>
18
19
class
JSONRPCRequest
;
20
21
namespace
{
22
23
static
RPCHelpMan getzmqnotifications()
24
{
25
return
RPCHelpMan{
26
"getzmqnotifications"
,
27
"Returns information about the active ZeroMQ notifications.\n"
,
28
{},
29
RPCResult{
30
RPCResult::Type::ARR
,
""
,
""
,
31
{
32
{
RPCResult::Type::OBJ
,
""
,
""
,
33
{
34
{
RPCResult::Type::STR
,
"type"
,
"Type of notification"
},
35
{
RPCResult::Type::STR
,
"address"
,
"Address of the publisher"
},
36
{
RPCResult::Type::NUM
,
"hwm"
,
"Outbound message high water mark"
},
37
}},
38
}
39
},
40
RPCExamples{
41
HelpExampleCli
(
"getzmqnotifications"
,
""
)
42
+
HelpExampleRpc
(
"getzmqnotifications"
,
""
)
43
},
44
[&](
const
RPCHelpMan& self,
const
JSONRPCRequest& request) -> UniValue
45
{
46
UniValue result(
UniValue::VARR
);
47
if
(
g_zmq_notification_interface
!=
nullptr
) {
48
for
(
const
auto
* n :
g_zmq_notification_interface
->GetActiveNotifiers()) {
49
UniValue obj(
UniValue::VOBJ
);
50
obj.pushKV(
"type"
, n->GetType());
51
obj.pushKV(
"address"
, n->GetAddress());
52
obj.pushKV(
"hwm"
, n->GetOutboundMessageHighWaterMark());
53
result.push_back(std::move(obj));
54
}
55
}
56
57
return
result;
58
},
59
};
60
}
61
62
const
CRPCCommand commands[]{
63
{
"zmq"
, &getzmqnotifications},
64
};
65
66
}
// anonymous namespace
67
68
void
RegisterZMQRPCCommands
(
CRPCTable
&
t
)
69
{
70
for
(
const
auto
& c : commands) {
71
t
.appendCommand(c.name, &c);
72
}
73
}
CRPCTable
RPC command dispatcher.
Definition
server.h:87
JSONRPCRequest
Definition
request.h:53
UniValue::VOBJ
@ VOBJ
Definition
univalue.h:24
UniValue::VARR
@ VARR
Definition
univalue.h:24
HelpExampleCli
std::string HelpExampleCli(const std::string &methodname, const std::string &args)
Definition
util.cpp:183
HelpExampleRpc
std::string HelpExampleRpc(const std::string &methodname, const std::string &args)
Definition
util.cpp:201
server.h
ByteUnit::t
@ t
Definition
strencodings.h:52
RPCResult::Type::STR
@ STR
Definition
util.h:300
RPCResult::Type::NUM
@ NUM
Definition
util.h:301
RPCResult::Type::ARR
@ ARR
Definition
util.h:299
RPCResult::Type::OBJ
@ OBJ
Definition
util.h:298
univalue.h
zmqabstractnotifier.h
g_zmq_notification_interface
std::unique_ptr< CZMQNotificationInterface > g_zmq_notification_interface
Definition
zmqnotificationinterface.cpp:213
zmqnotificationinterface.h
RegisterZMQRPCCommands
void RegisterZMQRPCCommands(CRPCTable &t)
Definition
zmqrpc.cpp:68
zmqrpc.h
Generated on
for Bitcoin Core by
1.17.0