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:
Sjors Provoost
2026-02-07 12:34:22 +01:00
parent a11297a904
commit 1e82fa498c
6 changed files with 58 additions and 17 deletions

View File

@@ -24,6 +24,7 @@ interface Mining $Proxy.wrap("interfaces::Mining") {
waitTipChanged @3 (context :Proxy.Context, currentTip: Data, timeout: Float64 = .maxDouble) -> (result: Common.BlockRef);
createNewBlock @4 (context :Proxy.Context, options: BlockCreateOptions, cooldown: Bool = true) -> (result: BlockTemplate);
checkBlock @5 (context :Proxy.Context, block: Data, options: BlockCheckOptions) -> (reason: Text, debug: Text, result: Bool);
interrupt @6 () -> ();
}
interface BlockTemplate $Proxy.wrap("interfaces::BlockTemplate") {