mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-14 12:43:40 +02:00
refactor: Add and use EnsureConnman in rpc code
This commit is contained in:
parent
faabeb854a
commit
fafb68add5
4 changed files with 70 additions and 51 deletions
|
|
@ -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!");
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue