@@ -786,38 +786,8 @@ impl<T: RawRepository> DistributedRepository<T> {
786
786
) ) ;
787
787
}
788
788
789
- // Construct a commit list starting from the next commit of the last finalized block to the `branch_commit`(the most recent commit of the branch)
790
- let ancestor_commits = self . raw . list_ancestors ( work_commit, Some ( 256 ) ) . await ?;
791
- let position = ancestor_commits
792
- . iter ( )
793
- . position ( |c| * c == last_header_commit)
794
- . expect ( "TODO: handle the case where it exceeds the limit." ) ;
795
- let commits = stream:: iter ( ancestor_commits. iter ( ) . take ( position) . rev ( ) . cloned ( ) . map (
796
- |c| {
797
- let raw = & self . raw ;
798
- async move { raw. read_semantic_commit ( c) . await . map ( |x| ( x, c) ) }
799
- } ,
800
- ) )
801
- . buffered ( 256 )
802
- . collect :: < Vec < _ > > ( )
803
- . await ;
804
- let mut commits = commits. into_iter ( ) . collect :: < Result < Vec < _ > , _ > > ( ) ?;
805
- // Add most recent commit of the branch to the list since it is not included in the ancestor commits
806
- commits. push ( (
807
- self . raw . read_semantic_commit ( work_commit) . await ?,
808
- work_commit,
809
- ) ) ;
810
- let commits = commits
811
- . into_iter ( )
812
- . map ( |( commit, hash) | {
813
- from_semantic_commit ( commit, reserved_state. clone ( ) )
814
- . map_err ( |e| ( e, hash) )
815
- . map ( |x| ( x, hash) )
816
- } )
817
- . collect :: < Result < Vec < _ > , _ > > ( )
818
- . map_err ( |( error, hash) | eyre ! ( "failed to convert the commit {}: {}" , hash, error) ) ?;
819
-
820
789
// Check the validity of the commit sequence
790
+ let commits = read_commits ( self , last_header_commit, work_commit) . await ?;
821
791
let last_header = self . get_last_finalized_block_header ( ) . await ?;
822
792
let mut verifier = CommitSequenceVerifier :: new ( last_header. clone ( ) , reserved_state. clone ( ) )
823
793
. map_err ( |e| eyre ! ( "verification error on commit {}: {}" , last_header_commit, e) ) ?;
0 commit comments