cuprate_blockchain::ops::blockchain

Function find_split_point

Source
pub fn find_split_point(
    block_ids: &[BlockHash],
    chronological_order: bool,
    table_block_heights: &impl DatabaseRo<BlockHeights>,
) -> Result<usize, RuntimeError>
Expand description

Find the split point between our chain and a list of BlockHashs from another chain.

This function accepts chains in chronological and reverse chronological order, however if the wrong order is specified the return value is meaningless.

For chronologically ordered chains this will return the index of the first unknown, for reverse chronologically ordered chains this will return the index of the first known.

If all blocks are known for chronologically ordered chains or unknown for reverse chronologically ordered chains then the length of the chain will be returned.

§Errors

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