/// Find and return the orphan chain tip with the highest accumulated difficulty.
Find and return the orphan chain tip with the highest accumulated difficulty.
Find and return the orphan chain tip with the highest accumulated difficulty .
fn find_strongest_orphan_tip<T: BlockchainBackend>(
    db: &T,
    orphan_chain_tips: Vec<BlockHash>,
    chain_strength_comparer: &dyn ChainStrengthComparer,
) -> Result<Option<BlockHeader>, ChainStorageError>
{
    let mut best_block_header: Option<BlockHeader> = None;
    for tip_hash in orphan_chain_tips {
        let header = fetch_orphan(db, tip_hash.clone())?.header;
        best_block_header = match best_block_header {
            Some(current_best) => match chain_strength_comparer.compare(&current_best, &header) {
                Ordering::Less => Some(header),
                Ordering::Greater | Ordering::Equal => Some(current_best),
            },
            None => Some(header),
        };
    }
    Ok(best_block_header)
}
fn find_strongest_orphan_tip < T : BlockchainBackend > ( db : & T , orphan_chain_tips : Vec < BlockHash > , chain_strength_comparer : & dyn ChainStrengthComparer , ) -> Result < Option < BlockHeader > , ChainStorageError > { let mut best_block_header : Option < BlockHeader > = None ; for tip_hash in orphan_chain_tips { let header = fetch_orphan ( db , tip_hash . clone ( ) ) ? . header ; best_block_header = match best_block_header { Some ( current_best ) => match chain_strength_comparer . compare ( & current_best , & header ) { Ordering :: Less => Some ( header ) , Ordering :: Greater | Ordering :: Equal => Some ( current_best ) , } , None => Some ( header ) , } ; } Ok ( best_block_header ) }
Find and return the orphan chain tip with the highest accumulated difficulty.
Find and return the orphan chain tip with the highest accumulated difficulty .
db
&T
orphan_chain_tips
Vec<BlockHash>
chain_strength_comparer
&dyn ChainStrengthComparer