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

Returns the earliest block with specified `status&lowbar;mask` flags set after the latest block _not_ having those flags&period;

== Synopsis

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

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
&lsqb;&lsqb;requires&lowbar;capability(0x7f2e1b0997e8), requires&lowbar;capability(0x7f2e26d1af48), requires&lowbar;capability(0x7f2e375e1028), requires&lowbar;capability(0x7f2e333683e8), requires&lowbar;capability(0x7f2e3542f3d8), requires&lowbar;capability(0x7f2e28a73f38)&rsqb;&rsqb;
xref:CBlockIndex.adoc[CBlockIndex] const&
GetFirstBlock(
    xref:CBlockIndex.adoc[CBlockIndex] const& upper&lowbar;block,
    uint32&lowbar;t status&lowbar;mask,
    xref:CBlockIndex.adoc[CBlockIndex] const* lower&lowbar;block = nullptr) const;
----

== Description

This function starts from `upper&lowbar;block`, which must have all `status&lowbar;mask` flags set, and iterates backwards through its ancestors&period; It continues as long as each block has all `status&lowbar;mask` flags set, until reaching the oldest ancestor or `lower&lowbar;block`&period;

== Return Value

A reference to the earliest block between `upper&lowbar;block` and `lower&lowbar;block`, inclusive, such that every block between the returned block and `upper&lowbar;block` has `status&lowbar;mask` flags set&period;

== Parameters

[cols="1,4"]
|===
| Name| Description
| *upper&lowbar;block*
| The starting block for the search, which must have all `status&lowbar;mask` flags set&period;
| *status&lowbar;mask*
| Bitmask specifying required status flags&period;
| *lower&lowbar;block*
| The earliest possible block to return&period; If null, the search can extend to the genesis block&period;
|===

== Preconditions

* `upper&lowbar;block` must have all `status&lowbar;mask` flags set&period;
* `lower&lowbar;block` must be null or an ancestor of `upper&lowbar;block`


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