Bitcoin Core 31.0.0
P2P Digital Currency
Loading...
Searching...
No Matches
Mining Class Referenceabstract

#include <mining.h>

Public Member Functions

virtual ~Mining ()=default
virtual bool isTestChain ()=0
 If this chain is exclusively used for testing.
virtual bool isInitialBlockDownload ()=0
 Returns whether IBD is still in progress.
virtual std::optional< BlockRefgetTip ()=0
 Returns the hash and height for the tip of this chain.
virtual std::optional< BlockRefwaitTipChanged (uint256 current_tip, MillisecondsDouble timeout=MillisecondsDouble::max())=0
 Waits for the connected tip to change.
virtual std::unique_ptr< BlockTemplatecreateNewBlock (const node::BlockCreateOptions &options={}, bool cooldown=true)=0
 Construct a new block template.
virtual void interrupt ()=0
 Interrupts createNewBlock and waitTipChanged.
virtual bool checkBlock (const CBlock &block, const node::BlockCheckOptions &options, std::string &reason, std::string &debug)=0
 Checks if a given block is valid.
virtual node::NodeContextcontext ()

Detailed Description

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

Definition at line 96 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 159 of file mining.h.

◆ createNewBlock()

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

Construct a new block template.

Parameters
[in]optionsoptions for creating the block
[in]cooldownwait for tip to be connected and IBD to complete. If the best header is ahead of the tip, wait for the tip to catch up. It's recommended to disable this on regtest and signets with only one miner, as these could stall.
Return values
BlockTemplatea block template.
std::nullptrif the node is shut down or interrupt() is called.

◆ getTip()

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

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

◆ interrupt()

virtual void interfaces::Mining::interrupt ( )
pure virtual

Interrupts createNewBlock and waitTipChanged.

◆ isInitialBlockDownload()

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

Returns whether IBD is still in progress.

◆ isTestChain()

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

If this chain is exclusively used for testing.

◆ 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 or interrupt() is called.

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