Bitcoin ABC
0.26.3
P2P Digital Currency
src
rpc
server_util.cpp
Go to the documentation of this file.
1
// Copyright (c) 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 <
rpc/server_util.h
>
6
7
#include <
net_processing.h
>
8
#include <
node/context.h
>
9
#include <
rpc/protocol.h
>
10
#include <
rpc/request.h
>
11
#include <
txmempool.h
>
12
#include <
util/system.h
>
13
#include <validation.h>
14
15
#include <any>
16
17
using
node::NodeContext
;
18
19
NodeContext
&
EnsureAnyNodeContext
(
const
std::any &context) {
20
auto
node_context = util::AnyPtr<NodeContext>(context);
21
if
(!node_context) {
22
throw
JSONRPCError
(
RPC_INTERNAL_ERROR
,
"Node context not found"
);
23
}
24
return
*node_context;
25
}
26
27
CTxMemPool
&
EnsureMemPool
(
const
NodeContext
&
node
) {
28
if
(!
node
.mempool) {
29
throw
JSONRPCError
(
RPC_CLIENT_MEMPOOL_DISABLED
,
30
"Mempool disabled or instance not found"
);
31
}
32
return
*
node
.mempool;
33
}
34
35
CTxMemPool
&
EnsureAnyMemPool
(
const
std::any &context) {
36
return
EnsureMemPool
(
EnsureAnyNodeContext
(context));
37
}
38
39
ChainstateManager
&
EnsureChainman
(
const
NodeContext
&
node
) {
40
if
(!
node
.chainman) {
41
throw
JSONRPCError
(
RPC_INTERNAL_ERROR
,
"Node chainman not found"
);
42
}
43
return
*
node
.chainman;
44
}
45
46
ChainstateManager
&
EnsureAnyChainman
(
const
std::any &context) {
47
return
EnsureChainman
(
EnsureAnyNodeContext
(context));
48
}
49
50
CConnman
&
EnsureConnman
(
const
NodeContext
&
node
) {
51
if
(!
node
.connman) {
52
throw
JSONRPCError
(
53
RPC_CLIENT_P2P_DISABLED
,
54
"Error: Peer-to-peer functionality missing or disabled"
);
55
}
56
return
*
node
.connman;
57
}
58
59
PeerManager
&
EnsurePeerman
(
const
NodeContext
&
node
) {
60
if
(!
node
.peerman) {
61
throw
JSONRPCError
(
62
RPC_CLIENT_P2P_DISABLED
,
63
"Error: Peer-to-peer functionality missing or disabled"
);
64
}
65
return
*
node
.peerman;
66
}
CConnman
Definition:
net.h:907
CTxMemPool
CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the ...
Definition:
txmempool.h:305
ChainstateManager
Provides an interface for creating and interacting with one or two chainstates: an IBD chainstate gen...
Definition:
validation.h:1062
PeerManager
Definition:
net_processing.h:48
node
Definition:
init.h:28
net_processing.h
context.h
JSONRPCError
UniValue JSONRPCError(int code, const std::string &message)
Definition:
request.cpp:57
request.h
protocol.h
RPC_CLIENT_MEMPOOL_DISABLED
@ RPC_CLIENT_MEMPOOL_DISABLED
Chain errors.
Definition:
protocol.h:86
RPC_INTERNAL_ERROR
@ RPC_INTERNAL_ERROR
Definition:
protocol.h:33
RPC_CLIENT_P2P_DISABLED
@ RPC_CLIENT_P2P_DISABLED
No valid connection manager instance found.
Definition:
protocol.h:81
EnsureAnyChainman
ChainstateManager & EnsureAnyChainman(const std::any &context)
Definition:
server_util.cpp:46
EnsureAnyMemPool
CTxMemPool & EnsureAnyMemPool(const std::any &context)
Definition:
server_util.cpp:35
EnsureAnyNodeContext
NodeContext & EnsureAnyNodeContext(const std::any &context)
Definition:
server_util.cpp:19
EnsureConnman
CConnman & EnsureConnman(const NodeContext &node)
Definition:
server_util.cpp:50
EnsurePeerman
PeerManager & EnsurePeerman(const NodeContext &node)
Definition:
server_util.cpp:59
EnsureMemPool
CTxMemPool & EnsureMemPool(const NodeContext &node)
Definition:
server_util.cpp:27
EnsureChainman
ChainstateManager & EnsureChainman(const NodeContext &node)
Definition:
server_util.cpp:39
server_util.h
node::NodeContext
NodeContext struct containing references to chain state and connection state.
Definition:
context.h:38
system.h
txmempool.h
Generated on Fri Jun 9 2023 02:37:24 for Bitcoin ABC by
1.9.1