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