Skip to content

Commit

Permalink
Exit strategy
Browse files Browse the repository at this point in the history
  • Loading branch information
timorleph committed Mar 6, 2024
1 parent 1d99d32 commit 78ae0b2
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions consensus/src/reconstruction/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,31 +180,26 @@ impl<H: Hasher> Service<H> {

/// Run the reconstruction service until terminated.
pub async fn run(mut self, mut terminator: Terminator) {
let mut exiting = false;
loop {
futures::select! {
n = self.notifications_from_runway.next() => match n {
Some(notification) => for output in self.handle_notification(notification) {
if !self.handle_output(output) {
exiting = true;
break;
return;
}
},
None => {
warn!(target: LOG_TARGET, "Notifications for reconstruction unexpectedly ended.");
exiting = true;
return;
}
},
_ = terminator.get_exit().fuse() => {
debug!(target: LOG_TARGET, "Received exit signal.");
exiting = true;
break;
}
}
if exiting {
debug!(target: LOG_TARGET, "Reconstruction decided to exit.");
terminator.terminate_sync().await;
break;
}
}
debug!(target: LOG_TARGET, "Reconstruction decided to exit.");
terminator.terminate_sync().await;
}
}

0 comments on commit 78ae0b2

Please sign in to comment.