Have createNewBlock() wait for a tip

- return null on shutdown instead of the last tip
- ignore timeout value node initialization

This allows consumers of BlockTemplate to safely
assume that a tip is connected, instead of having
to account for startup and early shutdown scenarios.
This commit is contained in:
Sjors Provoost
2025-02-03 18:11:00 +01:00
parent 64a2795fd4
commit 5315278e7c
2 changed files with 8 additions and 2 deletions

View File

@@ -101,10 +101,13 @@ public:
virtual std::optional<BlockRef> waitTipChanged(uint256 current_tip, MillisecondsDouble timeout = MillisecondsDouble::max()) = 0;
/**
* Construct a new block template
* Construct a new block template.
*
* During node initialization, this will wait until the tip is connected.
*
* @param[in] options options for creating the block
* @returns a block template
* @retval BlockTemplate a block template.
* @retval std::nullptr if the node is shut down.
*/
virtual std::unique_ptr<BlockTemplate> createNewBlock(const node::BlockCreateOptions& options = {}) = 0;