Module Store.Chain_traversal

The utility module used to traverse the chain.

val path : chain_store -> from_block:Block.t -> to_block:Block.t -> Block.t list option Lwt.t

path chain_store from_block to_block retrieves all blocks in chain_store from from_block to to_block (from_block is excluded from the result).

  • raises Invalid_arg

    if from_block is above to_block.

val common_ancestor : chain_store -> Block.t -> Block.t -> Block.t option Lwt.t

common_ancestor chain_store b1 b2 retrieves the common ancestor of b1 and b2 in chain_store. Returns None if no ancestor can be found.

val new_blocks : chain_store -> from_block:Block.t -> to_block:Block.t -> (Block.t * Block.t list) Lwt.t

new_blocks ~from_block ~to_block returns a pair (ancestor, path), where ancestor is the common ancestor of from_block and to_block and where path is the chain from ancestor (excluded) to to_block (included).

  • raises assert

    failure when the two provided blocks do not belong to the same chain.