Skip to main content

top_block_height

Function top_block_height 

Source
pub fn top_block_height(
    db: &BlockchainDatabase,
    tapes: &TapesReadTransaction<'_>,
) -> DbResult<BlockHeight>
Expand description

Retrieve the height of the top block.

This returns the height of the top block, not the chain_height.

For example:

  • The blockchain has 0 blocks => this returns Err(BlockchainError::NotFound)
  • The blockchain has 1 block (height 0) => this returns Ok(0)
  • The blockchain has 2 blocks (height 1) => this returns Ok(1)

Note that in cases where no blocks have been written to the database yet, an error is returned: Err(BlockchainError::NotFound).