throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled");
and replaces them with EnsureConnman
.
throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled");
and replaces them with EnsureConnman
.
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
Reviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.
ACK fad37e6c380bf96fa430217d5e2f43322d4718f9
This is a nice simplification. Tested the error message with the patch below. Used a similar patch with EnsurePeerman
. Tested that, with this refactor, functionality remains the same by applying a similar patch to the occurrences of if(!node.connman)
.
0--- a/src/rpc/net.cpp
1+++ b/src/rpc/net.cpp
2@@ -41,7 +41,7 @@ const std::vector<std::string> CONNECTION_TYPE_DOC{
3
4 CConnman& EnsureConnman(const NodeContext& node)
5 {
6- if (!node.connman) {
7+ if (true) {
8 throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled");
9 }
10 return *node.connman;
Concept ACK
There is one other instance in the ping
RPC that can be tackled with EnsurePeerman
:
0diff --git a/src/rpc/net.cpp b/src/rpc/net.cpp
1index 4d192ad95..fff7d3b60 100644
2--- a/src/rpc/net.cpp
3+++ b/src/rpc/net.cpp
4@@ -92,12 +92,10 @@ static RPCHelpMan ping()
5 [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
6 {
7 NodeContext& node = EnsureAnyNodeContext(request.context);
8- if (!node.peerman) {
9- throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled");
10- }
11+ PeerManager& peerman = EnsurePeerman(node);
12
13 // Request that each node send a ping during next message processing pass
14- node.peerman->SendPings();
15+ peerman.SendPings();
16 return NullUniValue;
17 },
18 };
Also, including <any>
isn’t needed in the new header src/rpc/net.h
.