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:

  • the cached Chain, and
  • the shared finalized ZebraDb reference.

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 and db.
  • 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 in chain or db.
  • Returns a list of block::Hashes in the chain, following the intersection with the chain.
  • Returns a list of block::Headers in the chain, following the intersection with the chain.
  • Return the depth of block hash from the chain tip. Searches chain for hash, then searches db.
  • 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 Heights in the chain, starting after the intersection hash on the chain.
  • Find the first hash that’s in the peer’s known_blocks, and in chain or db.
  • Return the hash for the block at height, if height is in chain or db.
  • Return the height for the block at hash, if hash is in chain or db.
  • Returns the median-time-past of the next block to be added to the best chain in non_finalized_state or db.
  • 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 of db.
  • Returns the tip block::Hash of chain. If there is no chain, returns the tip of db.
  • Returns the tip Height of chain. If there is no chain, returns the tip of db.