Function zebra_state::service::read::find::find_chain_hashes

source ·
pub fn find_chain_hashes<C>(
    chain: Option<C>,
    db: &ZebraDb,
    known_blocks: Vec<Hash>,
    stop: Option<Hash>,
    max_len: u32,
) -> Vec<Hash>
where C: AsRef<Chain>,
Expand description

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.

Starts from the first matching hash in the chain, ignoring all other hashes in known_blocks. If there is no matching hash in the chain, starts from the genesis hash.

Includes finalized and non-finalized blocks.

Stops the list of hashes after:

  • adding the tip,
  • adding the stop hash to the list, if it is in the chain, or
  • adding max_len hashes to the list.

Returns an empty list if the state is empty, and a partial or empty list if the found heights are concurrently modified.