[#node-CooldownIfHeadersAhead]
= xref:node.adoc[node]::CooldownIfHeadersAhead
:relfileprefix: ../
:mrdocs:

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&period; If the tip is sufficiently far behind, allow up to 20 seconds for the next tip update&period;

== Synopsis

Declared in `&lt;node&sol;miner&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
bool
CooldownIfHeadersAhead(
    xref:ChainstateManager.adoc[ChainstateManager]& chainman,
    xref:node/KernelNotifications.adoc[KernelNotifications]& kernel&lowbar;notifications,
    xref:interfaces/BlockRef.adoc[interfaces::BlockRef] const& last&lowbar;tip,
    bool& interrupt&lowbar;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&period; 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)&period;

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

== Return Value

false if interrupted&period;

== Parameters

[cols="1,4"]
|===
| Name| Description
| *chainman*
| The chainstate manager to query for the tip and headers&period;
| *kernel&lowbar;notifications*
| The notifications object used to wait during the cooldown&period;
| *last&lowbar;tip*
| tip at the start of the cooldown window&period;
| *interrupt&lowbar;mining*
| set to true to interrupt the cooldown&period;
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
