Bitcoin ABC
0.26.3
P2P Digital Currency
Loading...
Searching...
No Matches
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 <
avalanche/processor.h
>
8
#include <
common/args.h
>
9
#include <
net_processing.h
>
10
#include <
node/context.h
>
11
#include <
rpc/protocol.h
>
12
#include <
rpc/request.h
>
13
#include <
txmempool.h
>
14
#include <
util/any.h
>
15
#include <validation.h>
16
17
#include <any>
18
19
using
node::NodeContext
;
20
21
NodeContext
&
EnsureAnyNodeContext
(
const
std::any &context) {
22
auto
node_context
= util::AnyPtr<NodeContext>(context);
23
if
(!
node_context
) {
24
throw
JSONRPCError
(
RPC_INTERNAL_ERROR
,
"Node context not found"
);
25
}
26
return
*
node_context
;
27
}
28
29
CTxMemPool
&
EnsureMemPool
(
const
NodeContext
&
node
) {
30
if
(!
node
.mempool) {
31
throw
JSONRPCError
(
RPC_CLIENT_MEMPOOL_DISABLED
,
32
"Mempool disabled or instance not found"
);
33
}
34
return
*
node
.mempool;
35
}
36
37
CTxMemPool
&
EnsureAnyMemPool
(
const
std::any &context) {
38
return
EnsureMemPool
(
EnsureAnyNodeContext
(context));
39
}
40
41
ArgsManager
&
EnsureArgsman
(
const
NodeContext
&
node
) {
42
if
(!
node
.args) {
43
throw
JSONRPCError
(
RPC_INTERNAL_ERROR
,
"Node args not found"
);
44
}
45
return
*
node
.args;
46
}
47
48
ArgsManager
&
EnsureAnyArgsman
(
const
std::any &context) {
49
return
EnsureArgsman
(
EnsureAnyNodeContext
(context));
50
}
51
52
ChainstateManager
&
EnsureChainman
(
const
NodeContext
&
node
) {
53
if
(!
node
.chainman) {
54
throw
JSONRPCError
(
RPC_INTERNAL_ERROR
,
"Node chainman not found"
);
55
}
56
return
*
node
.chainman;
57
}
58
59
ChainstateManager
&
EnsureAnyChainman
(
const
std::any &context) {
60
return
EnsureChainman
(
EnsureAnyNodeContext
(context));
61
}
62
63
CConnman
&
EnsureConnman
(
const
NodeContext
&
node
) {
64
if
(!
node
.connman) {
65
throw
JSONRPCError
(
66
RPC_CLIENT_P2P_DISABLED
,
67
"Error: Peer-to-peer functionality missing or disabled"
);
68
}
69
return
*
node
.connman;
70
}
71
72
PeerManager
&
EnsurePeerman
(
const
NodeContext
&
node
) {
73
if
(!
node
.peerman) {
74
throw
JSONRPCError
(
75
RPC_CLIENT_P2P_DISABLED
,
76
"Error: Peer-to-peer functionality missing or disabled"
);
77
}
78
return
*
node
.peerman;
79
}
80
81
avalanche::Processor
&
EnsureAvalanche
(
const
NodeContext
&
node
) {
82
if
(!
node
.avalanche) {
83
throw
JSONRPCError
(
RPC_INTERNAL_ERROR
,
84
"Error: Avalanche processor missing or disabled"
);
85
}
86
return
*
node
.avalanche;
87
}
any.h
args.h
ArgsManager
Definition
args.h:96
CConnman
Definition
net.h:856
CTxMemPool
CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the ...
Definition
txmempool.h:212
ChainstateManager
Provides an interface for creating and interacting with one or two chainstates: an IBD chainstate gen...
Definition
validation.h:1219
PeerManager
Definition
net_processing.h:69
avalanche::Processor
Definition
processor.h:149
node
Definition
init.h:28
net_processing.h
context.h
processor.h
GetRand
T GetRand(T nMax=std::numeric_limits< T >::max()) noexcept
Generate a uniform random integer of type T in the range [0..nMax) nMax defaults to std::numeric_limi...
Definition
random.h:85
JSONRPCError
UniValue JSONRPCError(int code, const std::string &message)
Definition
request.cpp:58
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:59
EnsureAnyNodeContext
NodeContext & EnsureAnyNodeContext(const std::any &context)
Definition
server_util.cpp:21
EnsureMemPool
CTxMemPool & EnsureMemPool(const NodeContext &node)
Definition
server_util.cpp:29
EnsurePeerman
PeerManager & EnsurePeerman(const NodeContext &node)
Definition
server_util.cpp:72
EnsureChainman
ChainstateManager & EnsureChainman(const NodeContext &node)
Definition
server_util.cpp:52
EnsureAnyMemPool
CTxMemPool & EnsureAnyMemPool(const std::any &context)
Definition
server_util.cpp:37
EnsureArgsman
ArgsManager & EnsureArgsman(const NodeContext &node)
Definition
server_util.cpp:41
EnsureAvalanche
avalanche::Processor & EnsureAvalanche(const NodeContext &node)
Definition
server_util.cpp:81
EnsureConnman
CConnman & EnsureConnman(const NodeContext &node)
Definition
server_util.cpp:63
EnsureAnyArgsman
ArgsManager & EnsureAnyArgsman(const std::any &context)
Definition
server_util.cpp:48
server_util.h
node::NodeContext
NodeContext struct containing references to chain state and connection state.
Definition
context.h:43
txmempool.h
Generated on Thu Dec 26 2024 02:38:04 for Bitcoin ABC by
1.9.8