Function cuprate_blockchain::ops::block::add_block

source ·
pub fn add_block(
    block: &VerifiedBlockInformation,
    tables: &mut impl TablesMut,
) -> Result<(), RuntimeError>
Expand description

Add a VerifiedBlockInformation to the database.

This extracts all the data from the input block and maps/adds them to the appropriate database tables.

§Errors

This function returns RuntimeError::KeyNotFound if the input (if applicable) doesn’t exist or other RuntimeError’s on database errors.

§Panics

This function will panic if:

  • block.height > u32::MAX (not normally possible)
  • block.height is not != chain_height

§Already exists

This function will operate normally even if block already exists, i.e., this function will not return Err even if you call this function infinitely with the same block.