pub fn fetch_mmr_nodes_added_count<T>(checkpoints: &T, tip_height: u64, height: u64) -> Result<u32, ChainStorageError>
where
    T: ArrayLike<Value = MerkleCheckPoint>,
    ChainStorageError: From<T::Error>,
{
    let cp_count = checkpoints.len()?;
    match cp_count.checked_sub(1) {
        Some(last_index) => {
            let index = last_index.saturating_sub(tip_height.saturating_sub(height) as usize);
            let nodes_added = checkpoints
                .get(index)?
                .map(|cp| cp.accumulated_nodes_added_count())
                .unwrap_or(0);
            Ok(nodes_added)
        },
        None => Ok(0),
    }
}
/// Calculate the total leaf node count upto a specified height. If the height is less than the effective pruning
/// horizon the total number of nodes up to the effective pruned height is returned.
Calculate the total leaf node count upto a specified height. If the height is less than the effective pruning
horizon the total number of nodes up to the effective pruned height is returned.
Calculate the total leaf node count upto a specified height . If the height is less than the effective pruning horizon the total number of nodes up to the effective pruned height is returned .
pub fn fetch_mmr_nodes_added_count<T>(checkpoints: &T, tip_height: u64, height: u64) -> Result<u32, ChainStorageError>
where
    T: ArrayLike<Value = MerkleCheckPoint>,
    ChainStorageError: From<T::Error>,
{
    let cp_count = checkpoints.len()?;
    match cp_count.checked_sub(1) {
        Some(last_index) => {
            let index = last_index.saturating_sub(tip_height.saturating_sub(height) as usize);
            let nodes_added = checkpoints
                .get(index)?
                .map(|cp| cp.accumulated_nodes_added_count())
                .unwrap_or(0);
            Ok(nodes_added)
        },
        None => Ok(0),
    }
}
pub fn fetch_mmr_nodes_added_count < T > ( checkpoints : & T , tip_height : u64 , height : u64 ) -> Result < u32 , ChainStorageError > where T : ArrayLike < Value = MerkleCheckPoint > , ChainStorageError : From < T :: Error > , { let cp_count = checkpoints . len ( ) ? ; match cp_count . checked_sub ( 1 ) { Some ( last_index ) => { let index = last_index . saturating_sub ( tip_height . saturating_sub ( height ) as usize ) ; let nodes_added = checkpoints . get ( index ) ? . map ( | cp | cp . accumulated_nodes_added_count ( ) ) . unwrap_or ( 0 ) ; Ok ( nodes_added ) } , None => Ok ( 0 ) , } }
Calculate the total leaf node count upto a specified height.
Calculate the total leaf node count upto a specified height .
checkpoints
&T
tip_height
u64
height
u64
checkpoints
&T
tip_height
u64
height
u64