/// Find the DKG summary block that is between the given 'summary_block' and a
/// finalized tip 'block' (inclusive), and update the given summary_block to it.
Find the DKG summary block that is between the given 'summary_block' and a
finalized tip 'block' (inclusive), and update the given summary_block to it.
Find the DKG summary block that is between the given ' summary_block ' and a finalized tip ' block ' ( inclusive ) and update the given summary_block to it .
pub(crate) fn update_summary_block(
    consensus_pool: &dyn ConsensusPool,
    summary_block: &mut Block,
    finalized_tip: &Block,
) {
    let summary_height = summary_block.height();
    let start_height = finalized_tip.payload.as_ref().dkg_interval_start_height();
    match start_height.cmp(&summary_height) {
        Ordering::Less => {
            panic!(
                "DKG start_height {} of the given finalized block at height {} is less than summary block height {}",
                start_height, finalized_tip.height(), summary_height
            );
        }
        Ordering::Equal => (),
        Ordering::Greater => {
            // Update if we have a finalization at start_height
            if let Ok(finalization) = consensus_pool
                .validated()
                .finalization()
                .get_only_by_height(start_height)
            {
                let block = consensus_pool
                    .validated()
                    .block_proposal()
                    .get_by_height(start_height)
                    .find_map(|proposal| {
                        if proposal.content.get_hash() == &finalization.content.block {
                            Some(proposal.content.into_inner())
                        } else {
                            None
                        }
                    });
                *summary_block = block.unwrap_or_else(|| {
                    panic!(
                        "Consensus pool has finalization {:?}, but its referenced block is not found",
                        finalization
                    )
                });
                return;
            }
            // Otherwise, find the parent block at start_height
            *summary_block = ChainIterator::new(consensus_pool, finalized_tip.clone(), None)
                .take_while(|block| block.height() >= start_height)
                .find(|block| block.height() == start_height)
                .unwrap_or_else(|| {
                    panic!(
                        "No DKG summary block found between summary block at height {} and finalized tip at height {}",
                        summary_height,
                        finalized_tip.height(),
                    )
                });
            assert!(
                summary_block.payload.is_summary(),
                "Block at DKG start height {} does not have a DKG summary payload {:?}",
                start_height,
                summary_block.payload.as_ref()
            );
        }
    }
}
pub ( crate ) fn update_summary_block ( consensus_pool : & dyn ConsensusPool , summary_block : & mut Block , finalized_tip : & Block , ) { let summary_height = summary_block . height ( ) ; let start_height = finalized_tip . payload . as_ref ( ) . dkg_interval_start_height ( ) ; match start_height . cmp ( & summary_height ) { Ordering :: Less => { panic ! ( " " start_height finalized_tip height ( ) summary_height ) ; } Ordering :: Equal => ( ) , Ordering :: Greater => { // Update if we have a finalization at start_height if let Ok ( finalization ) = consensus_pool . validated ( ) . finalization ( ) . get_only_by_height ( start_height ) { let block = consensus_pool . validated ( ) . block_proposal ( ) . get_by_height ( start_height ) . find_map ( | proposal | { if proposal . content . get_hash ( ) == & finalization . content . block { Some ( proposal . content . into_inner ( ) ) } else { None } } ) ; * summary_block = block . unwrap_or_else ( | | { panic ! ( " " finalization ) } ) ; return ; } // Otherwise, find the parent block at start_height * summary_block = ChainIterator :: new ( consensus_pool , finalized_tip . clone ( ) , None ) . take_while ( | block | block . height ( ) >= start_height ) . find ( | block | block . height ( ) == start_height ) . unwrap_or_else ( | | { panic ! ( " " summary_height finalized_tip height ( ) ) } ) ; assert ! ( summary_block payload is_summary ( ) " " start_height summary_block payload as_ref ( ) ) ; } } }
Find the DKG summary block that is between the given 'summary_block' and a
finalized tip 'block' (inclusive), and update the given summary_block to it.
Find the DKG summary block that is between the given ' summary_block ' and a finalized tip ' block ' ( inclusive ) and update the given summary_block to it .
consensus_pool
&dyn ConsensusPool
summary_block
&mut Block
finalized_tip
&Block