From 7c094d2ff6e177a7b2a46a0b87e9b6915c999d20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Oliveira?= Date: Tue, 16 Jan 2024 00:58:53 +0000 Subject: [PATCH] add PeerId to ListenFailure (#567) --- swarm/CHANGELOG.md | 2 ++ swarm/src/behaviour.rs | 3 ++- swarm/src/lib.rs | 3 +++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/swarm/CHANGELOG.md b/swarm/CHANGELOG.md index 65dce4b002a..26022508d49 100644 --- a/swarm/CHANGELOG.md +++ b/swarm/CHANGELOG.md @@ -1,5 +1,7 @@ ## 0.44.1 +- Add `PeerId` to `ListenFailure` + - Implement `Clone` & `Copy` for `FromSwarm. This makes it easier to forward these events when wrapping other behaviours. See [PR 4825](https://github.com/libp2p/rust-libp2p/pull/4825). diff --git a/swarm/src/behaviour.rs b/swarm/src/behaviour.rs index 4be129a4eea..d3f3b491950 100644 --- a/swarm/src/behaviour.rs +++ b/swarm/src/behaviour.rs @@ -267,7 +267,7 @@ pub enum ToSwarm { /// The emphasis on a **new** candidate is important. /// Protocols MUST take care to only emit a candidate once per "source". /// For example, the observed address of a TCP connection does not change throughout its lifetime. - /// Thus, only one candidate should be emitted per connection. + /// Thus, only one candidate should be emitted per connection. /// /// This makes the report frequency of an address a meaningful data-point for consumers of this event. /// This address will be shared with all [`NetworkBehaviour`]s via [`FromSwarm::NewExternalAddrCandidate`]. @@ -487,6 +487,7 @@ pub struct ListenFailure<'a> { pub send_back_addr: &'a Multiaddr, pub error: &'a ListenError, pub connection_id: ConnectionId, + pub peer_id: Option, } /// [`FromSwarm`] variant that informs the behaviour that a new listener was created. diff --git a/swarm/src/lib.rs b/swarm/src/lib.rs index 0354f39cfdc..d673e41170e 100644 --- a/swarm/src/lib.rs +++ b/swarm/src/lib.rs @@ -741,6 +741,7 @@ where send_back_addr: &send_back_addr, error: &listen_error, connection_id: id, + peer_id: Some(peer_id), }, )); @@ -854,6 +855,7 @@ where send_back_addr: &send_back_addr, error: &error, connection_id: id, + peer_id: None, })); self.pending_swarm_events .push_back(SwarmEvent::IncomingConnectionError { @@ -957,6 +959,7 @@ where send_back_addr: &send_back_addr, error: &listen_error, connection_id, + peer_id: None, })); self.pending_swarm_events