mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-04 02:02:42 +02:00
mining: add interrupt()
Both waitTipChanged() and createNewBlock() can take a long time to return. Add a way for clients to interrupt them. The new m_interrupt_mining is safely accessed with a lock on m_tip_block_mutex, but it has no guard annotation. A more thorough solution is discussed here: https://github.com/bitcoin/bitcoin/pull/34184#discussion_r2743566474
This commit is contained in:
@@ -116,7 +116,7 @@ public:
|
||||
* @param[in] timeout how long to wait for a new tip (default is forever)
|
||||
*
|
||||
* @retval BlockRef hash and height of the current chain tip after this call.
|
||||
* @retval std::nullopt if the node is shut down.
|
||||
* @retval std::nullopt if the node is shut down or interrupt() is called.
|
||||
*/
|
||||
virtual std::optional<BlockRef> waitTipChanged(uint256 current_tip, MillisecondsDouble timeout = MillisecondsDouble::max()) = 0;
|
||||
|
||||
@@ -130,10 +130,15 @@ public:
|
||||
* regtest and signets with only one miner, as these
|
||||
* could stall.
|
||||
* @retval BlockTemplate a block template.
|
||||
* @retval std::nullptr if the node is shut down.
|
||||
* @retval std::nullptr if the node is shut down or interrupt() is called.
|
||||
*/
|
||||
virtual std::unique_ptr<BlockTemplate> createNewBlock(const node::BlockCreateOptions& options = {}, bool cooldown = true) = 0;
|
||||
|
||||
/**
|
||||
* Interrupts createNewBlock and waitTipChanged.
|
||||
*/
|
||||
virtual void interrupt() = 0;
|
||||
|
||||
/**
|
||||
* Checks if a given block is valid.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user