diff --git a/protocols/gossipsub/src/behaviour/tests.rs b/protocols/gossipsub/src/behaviour/tests.rs index 6cad719b5ab..fe861a674dd 100644 --- a/protocols/gossipsub/src/behaviour/tests.rs +++ b/protocols/gossipsub/src/behaviour/tests.rs @@ -268,6 +268,7 @@ where connection_id, endpoint: &fake_endpoint, remaining_established: active_connections, + cause: None, })); } } diff --git a/protocols/perf/src/client/behaviour.rs b/protocols/perf/src/client/behaviour.rs index 880bcdd9c83..5e430f8f0c1 100644 --- a/protocols/perf/src/client/behaviour.rs +++ b/protocols/perf/src/client/behaviour.rs @@ -116,6 +116,7 @@ impl NetworkBehaviour for Behaviour { connection_id: _, endpoint: _, remaining_established, + .. }) => { if remaining_established == 0 { assert!(self.connected.remove(&peer_id)); diff --git a/swarm/src/behaviour.rs b/swarm/src/behaviour.rs index 5070871a4c1..6f76f661961 100644 --- a/swarm/src/behaviour.rs +++ b/swarm/src/behaviour.rs @@ -32,8 +32,8 @@ use crate::connection::ConnectionId; use crate::dial_opts::DialOpts; use crate::listen_opts::ListenOpts; use crate::{ - ConnectionDenied, ConnectionHandler, DialError, ListenError, THandler, THandlerInEvent, - THandlerOutEvent, + ConnectionDenied, ConnectionError, ConnectionHandler, DialError, ListenError, THandler, + THandlerInEvent, THandlerOutEvent, }; use libp2p_core::{transport::ListenerId, ConnectedPoint, Endpoint, Multiaddr}; use libp2p_identity::PeerId; @@ -475,6 +475,7 @@ pub struct ConnectionClosed<'a> { pub peer_id: PeerId, pub connection_id: ConnectionId, pub endpoint: &'a ConnectedPoint, + pub cause: Option<&'a ConnectionError>, pub remaining_established: usize, } diff --git a/swarm/src/lib.rs b/swarm/src/lib.rs index cf2961cef6d..3d66941d976 100644 --- a/swarm/src/lib.rs +++ b/swarm/src/lib.rs @@ -907,6 +907,7 @@ where peer_id, connection_id: id, endpoint: &endpoint, + cause: error.as_ref(), remaining_established: num_established as usize, })); self.pending_swarm_events diff --git a/swarm/src/test.rs b/swarm/src/test.rs index 547277550bb..d49b504392a 100644 --- a/swarm/src/test.rs +++ b/swarm/src/test.rs @@ -301,6 +301,7 @@ where connection_id, endpoint, remaining_established, + cause, }: ConnectionClosed, ) { let mut other_closed_connections = self @@ -350,6 +351,7 @@ where connection_id, endpoint, remaining_established, + cause, })); } }