aboutsummaryrefslogtreecommitdiff
path: root/src/interfaces
diff options
context:
space:
mode:
authorSjors Provoost <sjors@sprovoost.nl>2024-06-07 11:22:44 +0200
committerSjors Provoost <sjors@sprovoost.nl>2024-06-18 18:47:51 +0200
commit8ecb6816781c7c7f423b501cbb2de3abd7250119 (patch)
tree33f35e170a988b4b4718eb9ddf55a1ae13742938 /src/interfaces
parent9c5cdf07f30f816cd134e2cd2dca9c27ef7067a5 (diff)
Introduce Mining interface
Start out with a single method isTestChain() that's used by the getblocktemplate RPC.
Diffstat (limited to 'src/interfaces')
-rw-r--r--src/interfaces/init.h2
-rw-r--r--src/interfaces/mining.h35
2 files changed, 37 insertions, 0 deletions
diff --git a/src/interfaces/init.h b/src/interfaces/init.h
index addc45aa26..094ead399d 100644
--- a/src/interfaces/init.h
+++ b/src/interfaces/init.h
@@ -7,6 +7,7 @@
#include <interfaces/chain.h>
#include <interfaces/echo.h>
+#include <interfaces/mining.h>
#include <interfaces/node.h>
#include <interfaces/wallet.h>
@@ -32,6 +33,7 @@ public:
virtual ~Init() = default;
virtual std::unique_ptr<Node> makeNode() { return nullptr; }
virtual std::unique_ptr<Chain> makeChain() { return nullptr; }
+ virtual std::unique_ptr<Mining> makeMining() { return nullptr; }
virtual std::unique_ptr<WalletLoader> makeWalletLoader(Chain& chain) { return nullptr; }
virtual std::unique_ptr<Echo> makeEcho() { return nullptr; }
virtual Ipc* ipc() { return nullptr; }
diff --git a/src/interfaces/mining.h b/src/interfaces/mining.h
new file mode 100644
index 0000000000..afcd8d1cda
--- /dev/null
+++ b/src/interfaces/mining.h
@@ -0,0 +1,35 @@
+// Copyright (c) 2024 The Bitcoin Core developers
+// Distributed under the MIT software license, see the accompanying
+// file COPYING or http://www.opensource.org/licenses/mit-license.php.
+
+#ifndef BITCOIN_INTERFACES_MINING_H
+#define BITCOIN_INTERFACES_MINING_H
+
+namespace node {
+struct NodeContext;
+} // namespace node
+
+namespace interfaces {
+
+//! Interface giving clients (RPC, Stratum v2 Template Provider in the future)
+//! ability to create block templates.
+
+class Mining
+{
+public:
+ virtual ~Mining() {}
+
+ //! If this chain is exclusively used for testing
+ virtual bool isTestChain() = 0;
+
+ //! Get internal node context. Useful for RPC and testing,
+ //! but not accessible across processes.
+ virtual node::NodeContext* context() { return nullptr; }
+};
+
+//! Return implementation of Mining interface.
+std::unique_ptr<Mining> MakeMining(node::NodeContext& node);
+
+} // namespace interfaces
+
+#endif // BITCOIN_INTERFACES_MINING_H