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§
- best_
relevant_ 🔒chain - Do a consistency check by checking the finalized tip before and after all other database queries.
- best_
tip - Returns the tip of the best chain in the non-finalized or finalized state.
- block_
locator - Create a block locator from
chain
anddb
. - block_
locator_ heights - Get the heights of the blocks for constructing a block_locator list.
- calculate_
median_ 🔒time_ past - Returns the median-time-past for the provided
relevant_chain
. - chain_
contains_ hash - Return true if
hash
is inchain
ordb
. - collect_
chain_ 🔒hashes - Returns a list of
block::Hash
es in the chain, following theintersection
with the chain. - collect_
chain_ 🔒headers - Returns a list of
block::Header
s in the chain, following theintersection
with the chain. - depth
- Return the depth of block
hash
from the chain tip. Searcheschain
forhash
, then searchesdb
. - finalized_
state_ contains_ block_ hash - 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.
- find_
chain_ hashes - 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. - find_
chain_ headers - 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. - find_
chain_ 🔒height_ range - Returns a range of
Height
s in the chain, starting after theintersection
hash on the chain. - find_
chain_ 🔒intersection - Find the first hash that’s in the peer’s
known_blocks
, and inchain
ordb
. - hash_
by_ height - Return the hash for the block at
height
, ifheight
is inchain
ordb
. - height_
by_ hash - Return the height for the block at
hash
, ifhash
is inchain
ordb
. - next_
median_ time_ past - Returns the median-time-past of the next block to be added to the best chain in
non_finalized_state
ordb
. - non_
finalized_ state_ contains_ block_ hash - 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.
- tip
- Returns the tip of
chain
. If there is no chain, returns the tip ofdb
. - tip_
hash - Returns the tip
block::Hash
ofchain
. If there is no chain, returns the tip ofdb
. - tip_
height - Returns the tip
Height
ofchain
. If there is no chain, returns the tip ofdb
. - tip_
with_ value_ balance - Returns the tip of
chain
with itsValueBalance
. If there is no chain, returns the tip ofdb
.