Bitcoin Core  28.1.0
P2P Digital Currency
Public Member Functions | List of all members
interfaces::Mining Class Referenceabstract

Interface giving clients (RPC, Stratum v2 Template Provider in the future) ability to create block templates. More...

#include <mining.h>

Public Member Functions

virtual ~Mining ()=default
 
virtual bool isTestChain ()=0
 If this chain is exclusively used for testing. More...
 
virtual bool isInitialBlockDownload ()=0
 Returns whether IBD is still in progress. More...
 
virtual std::optional< uint256getTipHash ()=0
 Returns the hash for the tip of this chain. More...
 
virtual std::unique_ptr< node::CBlockTemplatecreateNewBlock (const CScript &script_pub_key, const node::BlockCreateOptions &options={})=0
 Construct a new block template. More...
 
virtual bool processNewBlock (const std::shared_ptr< const CBlock > &block, bool *new_block)=0
 Processes new block. More...
 
virtual unsigned int getTransactionsUpdated ()=0
 Return the number of transaction updates in the mempool, used to decide whether to make a new block template. More...
 
virtual bool testBlockValidity (const CBlock &block, bool check_merkle_root, BlockValidationState &state)=0
 Check a block is completely valid from start to finish. More...
 
virtual node::NodeContextcontext ()
 Get internal node context. More...
 

Detailed Description

Interface giving clients (RPC, Stratum v2 Template Provider in the future) ability to create block templates.

Definition at line 28 of file mining.h.

Constructor & Destructor Documentation

◆ ~Mining()

virtual interfaces::Mining::~Mining ( )
virtualdefault

Member Function Documentation

◆ context()

virtual node::NodeContext* interfaces::Mining::context ( )
inlinevirtual

Get internal node context.

Useful for RPC and testing, but not accessible across processes.

Definition at line 78 of file mining.h.

◆ createNewBlock()

virtual std::unique_ptr<node::CBlockTemplate> interfaces::Mining::createNewBlock ( const CScript script_pub_key,
const node::BlockCreateOptions options = {} 
)
pure virtual

Construct a new block template.

Parameters
[in]script_pub_keythe coinbase output
[in]optionsoptions for creating the block
Returns
a block template
Here is the caller graph for this function:

◆ getTipHash()

virtual std::optional<uint256> interfaces::Mining::getTipHash ( )
pure virtual

Returns the hash for the tip of this chain.

Here is the caller graph for this function:

◆ getTransactionsUpdated()

virtual unsigned int interfaces::Mining::getTransactionsUpdated ( )
pure virtual

Return the number of transaction updates in the mempool, used to decide whether to make a new block template.

Here is the caller graph for this function:

◆ isInitialBlockDownload()

virtual bool interfaces::Mining::isInitialBlockDownload ( )
pure virtual

Returns whether IBD is still in progress.

Here is the caller graph for this function:

◆ isTestChain()

virtual bool interfaces::Mining::isTestChain ( )
pure virtual

If this chain is exclusively used for testing.

Here is the caller graph for this function:

◆ processNewBlock()

virtual bool interfaces::Mining::processNewBlock ( const std::shared_ptr< const CBlock > &  block,
bool *  new_block 
)
pure virtual

Processes new block.

A valid new block is automatically relayed to peers.

Parameters
[in]blockThe block we want to process.
[out]new_blockA boolean which is set to indicate if the block was first received via this call
Returns
If the block was processed, independently of block validity
Here is the caller graph for this function:

◆ testBlockValidity()

virtual bool interfaces::Mining::testBlockValidity ( const CBlock block,
bool  check_merkle_root,
BlockValidationState state 
)
pure virtual

Check a block is completely valid from start to finish.

Only works on top of our current best block. Does not check proof-of-work.

Parameters
[in]blockthe block to validate
[in]check_merkle_rootcall CheckMerkleRoot()
[out]statedetails of why a block failed to validate
Returns
false if it does not build on the current tip, or any of the checks fail
Here is the caller graph for this function:

The documentation for this class was generated from the following file: