Wait while the best known header extends the current chain tip AND at least one block is being added to the tip every 3 seconds. If the tip is sufficiently far behind, allow up to 20 seconds for the next tip update.

Synopsis

Declared in <node/miner.h>

bool
CooldownIfHeadersAhead(
    ChainstateManager& chainman,
    KernelNotifications& kernel_notifications,
    interfaces::BlockRef const& last_tip,
    bool& interrupt_mining);

Description

It’s not safe to keep waiting, because a malicious miner could announce a header and delay revealing the block, causing all other miners using this software to stall. At the same time, we need to balance between the default waiting time being brief, but not ending the cooldown prematurely when a random block is slow to download (or process).

The cooldown only applies to createNewBlock(), which is typically called once per connected client. Subsequent templates are provided by waitNext().

Return Value

false if interrupted.

Parameters

Name

Description

chainman

The chainstate manager to query for the tip and headers.

kernel_notifications

The notifications object used to wait during the cooldown.

last_tip

tip at the start of the cooldown window.

interrupt_mining

set to true to interrupt the cooldown.

Created with MrDocs