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 ) const DEFAULT_TASKS_CHANNEL_SIZE : usize = 1000 ;
@@ -164,6 +165,26 @@ impl<S: StateCommitterTrait> CommitmentManager<S> {
164165 results
165166 }
166167
168+ /// Fetches all ready commitment results from the state committer, until a revert result is
169+ /// received.
170+ pub ( crate ) async fn wait_for_revert_results (
171+ & mut self ,
172+ ) -> ( Vec < CommitmentTaskOutput > , RevertTaskOutput ) {
173+ let mut commitment_results = Vec :: new ( ) ;
174+ loop {
175+ // Sleep until a message is sent or the channel is closed.
176+ match self . results_receiver . recv ( ) . await {
177+ Some ( CommitterTaskOutput :: Commit ( commitment_task_result) ) => {
178+ commitment_results. push ( commitment_task_result)
179+ }
180+ Some ( CommitterTaskOutput :: Revert ( revert_task_result) ) => {
181+ return ( commitment_results, revert_task_result) ;
182+ }
183+ None => panic ! ( "Channel closed while waiting for revert results." ) ,
184+ }
185+ }
186+ }
187+
167188 // Private methods.
168189
169190 fn successfully_added_commitment_task (
You can’t perform that action at this time.
0 commit comments