pub fn top_block_height(
table_block_heights: &impl DatabaseRo<BlockHeights>,
) -> Result<BlockHeight, RuntimeError>
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(RuntimeError::KeyNotFound)
- 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(RuntimeError::KeyNotFound)
.
§Errors
This function returns RuntimeError::KeyNotFound
if the input (if applicable) doesn’t exist or other RuntimeError
’s on database errors.