Module zebra_state::service::read::find
source · Expand description
Finding and reading block hashes and headers, in response to peer requests.
In the functions in this module:
The block write task commits blocks to the finalized state before updating
chain
with a cached copy of the best non-finalized chain from
NonFinalizedState.chain_set
. Then the block commit task can commit additional blocks to
the finalized state after we’ve cloned the chain
.
This means that some blocks can be in both:
Functions§
- Do a consistency check by checking the finalized tip before and after all other database queries.
- Returns the tip of the best chain in the non-finalized or finalized state.
- Create a block locator from
chain
anddb
. - Get the heights of the blocks for constructing a block_locator list.
- Returns the median-time-past for the provided
relevant_chain
. - Return true if
hash
is inchain
ordb
. - Returns a list of
block::Hash
es in the chain, following theintersection
with the chain. - Returns a list of
block::Header
s in the chain, following theintersection
with the chain. - Return the depth of block
hash
from the chain tip. Searcheschain
forhash
, then searchesdb
. - Returns the location of the block if present in the finalized state. Returns None if the block hash is not found in the finalized state.
- Finds the first hash that’s in the peer’s
known_blocks
and the chain. Returns a list of hashes that follow that intersection, from the chain. - Finds the first hash that’s in the peer’s
known_blocks
and the chain. Returns a list of headers that follow that intersection, from the chain. - Returns a range of
Height
s in the chain, starting after theintersection
hash on the chain. - Find the first hash that’s in the peer’s
known_blocks
, and inchain
ordb
. - Return the hash for the block at
height
, ifheight
is inchain
ordb
. - Return the height for the block at
hash
, ifhash
is inchain
ordb
. - Returns the median-time-past of the next block to be added to the best chain in
non_finalized_state
ordb
. - Returns the location of the block if present in the non-finalized state. Returns None if the block hash is not found in the non-finalized state.
- Returns the tip of
chain
. If there is no chain, returns the tip ofdb
.