Trait CompareStrategy

Source
pub trait CompareStrategy<Block: BlockT, BlockInfo: Client<Block>> {
    type Error: Error;

    // Required method
    fn compare_block(
        &self,
        block: NumberFor<Block>,
        block_info: &BlockInfo,
    ) -> Result<Ordering, Self::Error>;
}
Expand description

Comparator used for binary searching the block history

Types implementing this trait represent some search target, which is to be found through binary search over block history. Note that this search target can be a single block defined by its slot or some other monotonically increasing block property, or a range of blocks defined by a range of slots or other property.

Required Associated Types§

Source

type Error: Error

Error type

Required Methods§

Source

fn compare_block( &self, block: NumberFor<Block>, block_info: &BlockInfo, ) -> Result<Ordering, Self::Error>

Compares a block against a search target.

§Returns
  • Ok(Ordering::Less) if the block is below the target
  • Ok(Ordering::Equal) if the block is at target
  • Ok(Ordering::Greater) if the block is above the target
  • Err if an error occured

Implementors§

Source§

impl<Block, BlockInfo> CompareStrategy<Block, BlockInfo> for AnyBlockInEpoch
where Block: BlockT, BlockInfo: SidechainInfo<Block>,

Source§

type Error = <BlockInfo as SidechainInfo<Block>>::Error

Source§

impl<Block, BlockInfo> CompareStrategy<Block, BlockInfo> for AnyBlockInSlotRange
where Block: BlockT, BlockInfo: SidechainInfo<Block>,

Source§

type Error = <BlockInfo as SidechainInfo<Block>>::Error

Source§

impl<Block, BlockInfo> CompareStrategy<Block, BlockInfo> for LastBlockInEpoch
where Block: BlockT, BlockInfo: SidechainInfo<Block>,

Source§

type Error = <BlockInfo as SidechainInfo<Block>>::Error

Source§

impl<Block, BlockInfo> CompareStrategy<Block, BlockInfo> for LatestBlockInSlotRange<Block>
where Block: BlockT, BlockInfo: SidechainInfo<Block>,

Source§

type Error = <BlockInfo as SidechainInfo<Block>>::Error