File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
crates/apollo_batcher/src/commitment_manager Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ use crate::commitment_manager::types::{
2424 CommitterTaskInput ,
2525 CommitterTaskOutput ,
2626 FinalBlockCommitment ,
27+ RevertTaskOutput ,
2728} ;
2829
2930pub ( crate ) type CommitmentManagerResult < T > = Result < T , CommitmentManagerError > ;
@@ -142,6 +143,26 @@ impl<S: StateCommitterTrait> CommitmentManager<S> {
142143 results
143144 }
144145
146+ /// Fetches all ready commitment results from the state committer, until a revert result is
147+ /// received.
148+ pub ( crate ) async fn wait_for_revert_results (
149+ & mut self ,
150+ ) -> ( Vec < CommitmentTaskOutput > , RevertTaskOutput ) {
151+ let mut commitment_results = Vec :: new ( ) ;
152+ loop {
153+ // Sleep until a message is sent or the channel is closed.
154+ match self . results_receiver . recv ( ) . await {
155+ Some ( CommitterTaskOutput :: Commit ( commitment_task_result) ) => {
156+ commitment_results. push ( commitment_task_result)
157+ }
158+ Some ( CommitterTaskOutput :: Revert ( revert_task_result) ) => {
159+ return ( commitment_results, revert_task_result) ;
160+ }
161+ None => panic ! ( "Channel closed while waiting for revert results." ) ,
162+ }
163+ }
164+ }
165+
145166 // Private methods.
146167
147168 fn successfully_added_commitment_task (
You can’t perform that action at this time.
0 commit comments