mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-03-28 16:36:04 +01:00
Merge bitcoin/bitcoin#21719: refactor: Add and use EnsureConnman in rpc code
fafb68add5refactor: Add and use EnsureConnman in rpc code (MarcoFalke)faabeb854arefactor: Mark member functions const (MarcoFalke) Pull request description: This removes the 10 occurrences of `throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled");` and replaces them with `EnsureConnman`. ACKs for top commit: jarolrod: re-ACKfafb68add5theStack: ACKfafb68add5ryanofsky: Code review ACKfafb68add5Tree-SHA512: 84c63cfe31e548645d906f7191a3526c7bea99ed0d54c2a75c2041452a44fe149ede343d8e1943b0e7770816c828bb047dfec8bc541a1f2b89920a126ee54d68
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
#include <pow.h>
|
||||
#include <rpc/blockchain.h>
|
||||
#include <rpc/mining.h>
|
||||
#include <rpc/net.h>
|
||||
#include <rpc/server.h>
|
||||
#include <rpc/util.h>
|
||||
#include <script/descriptor.h>
|
||||
@@ -671,11 +672,9 @@ static RPCHelpMan getblocktemplate()
|
||||
if (strMode != "template")
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid mode");
|
||||
|
||||
if(!node.connman)
|
||||
throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled");
|
||||
|
||||
if (!Params().IsTestChain()) {
|
||||
if (node.connman->GetNodeCount(ConnectionDirection::Both) == 0) {
|
||||
const CConnman& connman = EnsureConnman(node);
|
||||
if (connman.GetNodeCount(ConnectionDirection::Both) == 0) {
|
||||
throw JSONRPCError(RPC_CLIENT_NOT_CONNECTED, PACKAGE_NAME " is not connected!");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user