Introduce Mining interface

Start out with a single method isTestChain() that's used by the getblocktemplate RPC.
This commit is contained in:
Sjors Provoost
2024-06-07 11:22:44 +02:00
parent 9c5cdf07f3
commit 8ecb681678
14 changed files with 85 additions and 3 deletions

View File

@@ -16,6 +16,7 @@
#include <core_io.h>
#include <deploymentinfo.h>
#include <deploymentstatus.h>
#include <interfaces/mining.h>
#include <key_io.h>
#include <net.h>
#include <node/context.h>
@@ -45,6 +46,7 @@
using node::BlockAssembler;
using node::CBlockTemplate;
using interfaces::Mining;
using node::NodeContext;
using node::RegenerateCommitments;
using node::UpdateTime;
@@ -724,7 +726,8 @@ static RPCHelpMan getblocktemplate()
if (strMode != "template")
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid mode");
if (!chainman.GetParams().IsTestChain()) {
Mining& miner = EnsureMining(node);
if (!miner.isTestChain()) {
const CConnman& connman = EnsureConnman(node);
if (connman.GetNodeCount(ConnectionDirection::Both) == 0) {
throw JSONRPCError(RPC_CLIENT_NOT_CONNECTED, PACKAGE_NAME " is not connected!");