@@ -593,27 +593,24 @@ impl<T: RawRepository> DistributedRepository<T> {
593
593
. map_err ( |e| eyre ! ( "verification error on commit {}: {}" , hash, e) ) ?;
594
594
}
595
595
596
- // Check whether the commit sequence is in the transaction phase.
596
+ // Create agenda commit
597
597
let mut transactions = Vec :: new ( ) ;
598
-
599
598
for ( commit, _) in commits {
600
599
if let Commit :: Transaction ( t) = commit {
601
600
transactions. push ( t. clone ( ) ) ;
602
- } else {
603
- return Err ( eyre ! (
604
- "branch {} is not in the transaction phase" ,
605
- WORK_BRANCH_NAME
606
- ) ) ;
607
601
}
608
602
}
609
-
610
603
let agenda = Agenda {
611
604
author,
612
605
timestamp : get_timestamp ( ) ,
613
606
transactions_hash : Agenda :: calculate_transactions_hash ( & transactions) ,
614
607
height : last_header. height + 1 ,
615
608
} ;
616
609
let agenda_commit = Commit :: Agenda ( agenda. clone ( ) ) ;
610
+ verifier. apply_commit ( & agenda_commit) . map_err ( |_| {
611
+ eyre ! ( "agenda commit cannot be created on top of the current commit sequence" )
612
+ } ) ?;
613
+
617
614
let semantic_commit = to_semantic_commit ( & agenda_commit, reserved_state) ?;
618
615
619
616
self . raw . checkout_clean ( ) . await ?;
@@ -697,37 +694,6 @@ impl<T: RawRepository> DistributedRepository<T> {
697
694
. map_err ( |e| eyre ! ( "verification error on commit {}: {}" , hash, e) ) ?;
698
695
}
699
696
700
- // Check whether the commit sequence is in the agenda proof phase or
701
- // extra-agenda transaction phase.
702
- // TODO: WHAT THE FUCK ARE YOU DOING HERE???
703
- let ( last_commit, _) = commits
704
- . last ( )
705
- . ok_or_else ( || eyre ! ( "branch doesn't contain any commit" ) ) ?
706
- . clone ( ) ;
707
- match last_commit {
708
- Commit :: AgendaProof ( _) => ( ) ,
709
- Commit :: ExtraAgendaTransaction ( _) => ( ) ,
710
- x => return Err ( eyre ! ( "a block can't be made on top of a commit {:?}" , x) ) ,
711
- }
712
-
713
- let mut transactions = Vec :: new ( ) ;
714
-
715
- for ( commit, _) in commits. clone ( ) {
716
- match commit {
717
- Commit :: Transaction ( t) => transactions. push ( t. clone ( ) ) ,
718
- Commit :: Agenda ( _) => { }
719
- Commit :: AgendaProof ( _) => { }
720
- Commit :: ExtraAgendaTransaction ( _) => { }
721
- Commit :: ChatLog ( _) => { }
722
- _ => {
723
- return Err ( eyre ! (
724
- "branch {} is not in the agenda proof phase or extra-agenda transaction phase" ,
725
- WORK_BRANCH_NAME
726
- ) )
727
- }
728
- }
729
- }
730
-
731
697
// Verify `finalization_proof`
732
698
let fp_commit_hash = self . raw . locate_branch ( FP_BRANCH_NAME . into ( ) ) . await ?;
733
699
let fp_semantic_commit = self . raw . read_semantic_commit ( fp_commit_hash) . await ?;
@@ -751,6 +717,10 @@ impl<T: RawRepository> DistributedRepository<T> {
751
717
version : SIMPERBY_CORE_PROTOCOL_VERSION . to_string ( ) ,
752
718
} ;
753
719
let block_commit = Commit :: Block ( block_header. clone ( ) ) ;
720
+ verifier. apply_commit ( & block_commit) . map_err ( |_| {
721
+ eyre ! ( "block commit cannot be created on top of the current commit sequence" )
722
+ } ) ?;
723
+
754
724
let semantic_commit = to_semantic_commit ( & block_commit, reserved_state) ?;
755
725
756
726
self . raw . checkout_clean ( ) . await ?;
@@ -797,22 +767,12 @@ impl<T: RawRepository> DistributedRepository<T> {
797
767
. map_err ( |e| eyre ! ( "verification error on commit {}: {}" , hash, e) ) ?;
798
768
}
799
769
800
- // Check whether the commit sequence is in agenda proof phase or extra-agenda transaction phase
801
- let ( last_commit, _) = commits
802
- . last ( )
803
- . ok_or_else ( || eyre ! ( "work branch does not contain any commit" ) ) ?;
804
- match last_commit {
805
- Commit :: AgendaProof ( _) => { }
806
- Commit :: ExtraAgendaTransaction ( _) => { }
807
- x => {
808
- return Err ( eyre ! (
809
- "an extra-agenda transaction commit cannot be created on top of a commit of type {:?}" ,
810
- x
811
- ) )
812
- }
813
- }
814
-
815
770
let extra_agenda_tx_commit = Commit :: ExtraAgendaTransaction ( transaction. clone ( ) ) ;
771
+ verifier. apply_commit ( & extra_agenda_tx_commit) . map_err ( |_| {
772
+ eyre ! (
773
+ "extra-agenda transaction commit cannot be created on top of the current commit sequence"
774
+ )
775
+ } ) ?;
816
776
817
777
let semantic_commit = to_semantic_commit ( & extra_agenda_tx_commit, reserved_state) ?;
818
778
0 commit comments