Skip to content

Commit

Permalink
feat: cancel the session if leader disconnects
Browse files Browse the repository at this point in the history
  • Loading branch information
raimundo-henriques committed Nov 14, 2023
1 parent 81960a8 commit b35e009
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -384,11 +384,18 @@ async fn main() -> Result<(), Box<dyn Error>> {
if result.is_none() {
let Some(disconnected) = participants.iter().find(|(_, (_, id))| *id == peer_id) else {
println!("Connection error, please try again.");
continue;
std::process::exit(1);
};

let disconnected = disconnected.1.0.clone();

if swarm.connected_peers().count() == 0 {
println!("The benchmark leader cancelled the session.");
std::process::exit(1);
}

println!("\nParticipant {disconnected} disconnected");

let msg = Msg::Quit(peer_id, disconnected).serialize()?;
swarm
.behaviour_mut()
Expand Down

0 comments on commit b35e009

Please sign in to comment.