Bitcoin Core 29.99.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< BlockRefgetTip ()=0
 Returns the hash and height for the tip of this chain. More...
 
virtual std::optional< BlockRefwaitTipChanged (uint256 current_tip, MillisecondsDouble timeout=MillisecondsDouble::max())=0
 Waits for the connected tip to change. More...
 
virtual std::unique_ptr< BlockTemplatecreateNewBlock (const node::BlockCreateOptions &options={})=0
 Construct a new block template. More...
 
virtual bool checkBlock (const CBlock &block, const node::BlockCheckOptions &options, std::string &reason, std::string &debug)=0
 Checks if a given block is valid. 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 79 of file mining.h.

Constructor & Destructor Documentation

◆ ~Mining()

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

Member Function Documentation

◆ checkBlock()

virtual bool interfaces::Mining::checkBlock ( const CBlock block,
const node::BlockCheckOptions options,
std::string &  reason,
std::string &  debug 
)
pure virtual

Checks if a given block is valid.

Parameters
[in]blockthe block to check
[in]optionsverification options: the proof-of-work check can be skipped in order to verify a template generated by external software.
[out]reasonfailure reason (BIP22)
[out]debugmore detailed rejection reason
Returns
whether the block is valid

For signets the challenge verification is skipped when check_pow is false.

◆ 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 134 of file mining.h.

◆ createNewBlock()

virtual std::unique_ptr< BlockTemplate > interfaces::Mining::createNewBlock ( const node::BlockCreateOptions options = {})
pure virtual

Construct a new block template.

During node initialization, this will wait until the tip is connected.

Parameters
[in]optionsoptions for creating the block
Return values
BlockTemplatea block template.
std::nullptrif the node is shut down.
Here is the caller graph for this function:

◆ getTip()

virtual std::optional< BlockRef > interfaces::Mining::getTip ( )
pure virtual

Returns the hash and height for the tip of this chain.

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:

◆ waitTipChanged()

virtual std::optional< BlockRef > interfaces::Mining::waitTipChanged ( uint256  current_tip,
MillisecondsDouble  timeout = MillisecondsDouble::max() 
)
pure virtual

Waits for the connected tip to change.

During node initialization, this will wait until the tip is connected (regardless of timeout).

Parameters
[in]current_tipblock hash of the current chain tip. Function waits for the chain tip to differ from this.
[in]timeouthow long to wait for a new tip (default is forever)
Return values
BlockRefhash and height of the current chain tip after this call.
std::nulloptif the node is shut down.
Here is the caller graph for this function:

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