File tree Expand file tree Collapse file tree 1 file changed +9
-15
lines changed
Expand file tree Collapse file tree 1 file changed +9
-15
lines changed Original file line number Diff line number Diff line change @@ -647,25 +647,19 @@ fn fetch_tip_and_latest_blocks(
647647 }
648648 }
649649 agreement_cp
650+ . ok_or_else ( || Error :: Message ( "cannot find agreement block with server" . to_string ( ) ) ) ?
650651 } ;
651652
652- let agreement_height = agreement_cp. as_ref ( ) . map ( CheckPoint :: height) ;
653-
654- let new_tip = new_blocks
653+ let extension = new_blocks
655654 . iter ( )
656- // Prune `new_blocks` to only include blocks that are actually new.
657- . filter ( |( height, _) | Some ( * <& u32 >:: clone ( height) ) > agreement_height)
658- . map ( |( height, hash) | BlockId {
659- height : * height,
660- hash : * hash,
661- } )
662- . fold ( agreement_cp, |prev_cp, block| {
663- Some ( match prev_cp {
664- Some ( cp) => cp. push ( block) . ok ( ) ?,
665- None => CheckPoint :: new ( block) ,
666- } )
655+ . filter ( {
656+ let agreement_height = agreement_cp. height ( ) ;
657+ move |( height, _) | * * height > agreement_height
667658 } )
668- . ok_or_else ( || Error :: Message ( "failed to construct new checkpoint tip" . to_string ( ) ) ) ?;
659+ . map ( |( & height, & hash) | BlockId { height, hash } ) ;
660+ let new_tip = agreement_cp
661+ . extend ( extension)
662+ . expect ( "extension heights already checked to be greater than agreement height" ) ;
669663
670664 Ok ( ( new_tip, new_blocks) )
671665}
You can’t perform that action at this time.
0 commit comments