diff --git a/swap/src/protocol/alice/event_loop.rs b/swap/src/protocol/alice/event_loop.rs index 2bde901b..7f90db25 100644 --- a/swap/src/protocol/alice/event_loop.rs +++ b/swap/src/protocol/alice/event_loop.rs @@ -311,15 +311,11 @@ where SwarmEvent::IncomingConnectionError { send_back_addr: address, error, .. } => { tracing::warn!(%address, "Failed to set up connection with peer. Error {:#}", error); } - SwarmEvent::ConnectionClosed { peer_id: peer, num_established, endpoint, cause } if num_established == 0 => { - match cause { - Some(error) => { - tracing::warn!(%peer, address = %endpoint.get_remote_address(), "Lost connection. Error {:#}", error); - }, - None => { - tracing::info!(%peer, address = %endpoint.get_remote_address(), "Successfully closed connection"); - } - } + SwarmEvent::ConnectionClosed { peer_id: peer, num_established, endpoint, cause: Some(error) } if num_established == 0 => { + tracing::warn!(%peer, address = %endpoint.get_remote_address(), "Lost connection. Error {:#}", error); + } + SwarmEvent::ConnectionClosed { peer_id: peer, num_established, endpoint, cause: None } if num_established == 0 => { + tracing::info!(%peer, address = %endpoint.get_remote_address(), "Successfully closed connection"); } SwarmEvent::NewListenAddr(address) => { tracing::info!(%address, "New listen address detected"); diff --git a/swap/src/protocol/bob/event_loop.rs b/swap/src/protocol/bob/event_loop.rs index 4fe347bf..a596b9ed 100644 --- a/swap/src/protocol/bob/event_loop.rs +++ b/swap/src/protocol/bob/event_loop.rs @@ -176,17 +176,13 @@ impl EventLoop { SwarmEvent::Dialing(peer_id) if peer_id == self.alice_peer_id => { tracing::debug!("Dialling Alice at {}", peer_id); } - SwarmEvent::ConnectionClosed { peer_id, endpoint, num_established, cause } if peer_id == self.alice_peer_id && num_established == 0 => { - match cause { - Some(error) => { - tracing::warn!("Lost connection to Alice at {}, cause: {}", endpoint.get_remote_address(), error); - }, - None => { - // no error means the disconnection was requested - tracing::info!("Successfully closed connection to Alice"); - return; - } - } + SwarmEvent::ConnectionClosed { peer_id, endpoint, num_established, cause: Some(error) } if peer_id == self.alice_peer_id && num_established == 0 => { + tracing::warn!("Lost connection to Alice at {}, cause: {}", endpoint.get_remote_address(), error); + } + SwarmEvent::ConnectionClosed { peer_id, num_established, cause: None, .. } if peer_id == self.alice_peer_id && num_established == 0 => { + // no error means the disconnection was requested + tracing::info!("Successfully closed connection to Alice"); + return; } SwarmEvent::UnreachableAddr { peer_id, address, attempts_remaining, error } if peer_id == self.alice_peer_id && attempts_remaining == 0 => { tracing::warn!(%address, "Failed to dial Alice: {}", error);