Reduce level of indentation of match statements

pull/576/head
Thomas Eizinger 3 years ago
parent f1182f97c0
commit b7064578ca
No known key found for this signature in database
GPG Key ID: 651AC83A6C6C8B96

@ -311,15 +311,11 @@ where
SwarmEvent::IncomingConnectionError { send_back_addr: address, error, .. } => { SwarmEvent::IncomingConnectionError { send_back_addr: address, error, .. } => {
tracing::warn!(%address, "Failed to set up connection with peer. Error {:#}", 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 => { SwarmEvent::ConnectionClosed { peer_id: peer, num_established, endpoint, cause: Some(error) } if num_established == 0 => {
match cause {
Some(error) => {
tracing::warn!(%peer, address = %endpoint.get_remote_address(), "Lost connection. Error {:#}", 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: None } if num_established == 0 => {
tracing::info!(%peer, address = %endpoint.get_remote_address(), "Successfully closed connection");
} }
SwarmEvent::NewListenAddr(address) => { SwarmEvent::NewListenAddr(address) => {
tracing::info!(%address, "New listen address detected"); tracing::info!(%address, "New listen address detected");

@ -176,18 +176,14 @@ impl EventLoop {
SwarmEvent::Dialing(peer_id) if peer_id == self.alice_peer_id => { SwarmEvent::Dialing(peer_id) if peer_id == self.alice_peer_id => {
tracing::debug!("Dialling Alice at {}", 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 => { SwarmEvent::ConnectionClosed { peer_id, endpoint, num_established, cause: Some(error) } 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); tracing::warn!("Lost connection to Alice at {}, cause: {}", endpoint.get_remote_address(), error);
}, }
None => { 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 // no error means the disconnection was requested
tracing::info!("Successfully closed connection to Alice"); tracing::info!("Successfully closed connection to Alice");
return; return;
} }
}
}
SwarmEvent::UnreachableAddr { peer_id, address, attempts_remaining, error } if peer_id == self.alice_peer_id && attempts_remaining == 0 => { 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); tracing::warn!(%address, "Failed to dial Alice: {}", error);

Loading…
Cancel
Save