Bitcoin Core 28.0.0
P2P Digital Currency
Loading...
Searching...
No Matches
mining.h
Go to the documentation of this file.
1// Copyright (c) 2024 The Bitcoin Core developers
2// Distributed under the MIT software license, see the accompanying
3// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
5#ifndef BITCOIN_INTERFACES_MINING_H
6#define BITCOIN_INTERFACES_MINING_H
7
8#include <node/types.h>
9#include <uint256.h>
10
11#include <memory>
12#include <optional>
13
14namespace node {
15struct CBlockTemplate;
16struct NodeContext;
17} // namespace node
18
20class CBlock;
21class CScript;
22
23namespace interfaces {
24
27
28class Mining
29{
30public:
31 virtual ~Mining() = default;
32
34 virtual bool isTestChain() = 0;
35
37 virtual bool isInitialBlockDownload() = 0;
38
40 virtual std::optional<uint256> getTipHash() = 0;
41
49 virtual std::unique_ptr<node::CBlockTemplate> createNewBlock(const CScript& script_pub_key, const node::BlockCreateOptions& options={}) = 0;
50
58 virtual bool processNewBlock(const std::shared_ptr<const CBlock>& block, bool* new_block) = 0;
59
62 virtual unsigned int getTransactionsUpdated() = 0;
63
74 virtual bool testBlockValidity(const CBlock& block, bool check_merkle_root, BlockValidationState& state) = 0;
75
78 virtual node::NodeContext* context() { return nullptr; }
79};
80
82std::unique_ptr<Mining> MakeMining(node::NodeContext& node);
83
84} // namespace interfaces
85
86#endif // BITCOIN_INTERFACES_MINING_H
Definition block.h:69
Serialized script, used inside transaction inputs and outputs.
Definition script.h:414
Interface giving clients (RPC, Stratum v2 Template Provider in the future) ability to create block te...
Definition mining.h:29
virtual ~Mining()=default
virtual bool testBlockValidity(const CBlock &block, bool check_merkle_root, BlockValidationState &state)=0
Check a block is completely valid from start to finish.
virtual bool processNewBlock(const std::shared_ptr< const CBlock > &block, bool *new_block)=0
Processes new block.
virtual bool isInitialBlockDownload()=0
Returns whether IBD is still in progress.
virtual unsigned int getTransactionsUpdated()=0
Return the number of transaction updates in the mempool, used to decide whether to make a new block t...
virtual std::optional< uint256 > getTipHash()=0
Returns the hash for the tip of this chain.
virtual std::unique_ptr< node::CBlockTemplate > createNewBlock(const CScript &script_pub_key, const node::BlockCreateOptions &options={})=0
Construct a new block template.
virtual bool isTestChain()=0
If this chain is exclusively used for testing.
virtual node::NodeContext * context()
Get internal node context.
Definition mining.h:78
std::unique_ptr< Mining > MakeMining(node::NodeContext &node)
Return implementation of Mining interface.
is a home for public enum and struct type definitions that are used by internally by node code,...
NodeContext struct containing references to chain state and connection state.
Definition context.h:55