Skip to content

Commit

Permalink
add PeerId to ListenFailure
Browse files Browse the repository at this point in the history
  • Loading branch information
jxs committed Jan 15, 2024
1 parent 5f90ab3 commit b901215
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions swarm/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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).
Expand Down
3 changes: 2 additions & 1 deletion swarm/src/behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ pub enum ToSwarm<TOutEvent, TInEvent> {
/// 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`].
Expand Down Expand Up @@ -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<PeerId>,
}

/// [`FromSwarm`] variant that informs the behaviour that a new listener was created.
Expand Down
3 changes: 3 additions & 0 deletions swarm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -741,6 +741,7 @@ where
send_back_addr: &send_back_addr,
error: &listen_error,
connection_id: id,
peer_id: Some(peer_id),
},
));

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -957,6 +959,7 @@ where
send_back_addr: &send_back_addr,
error: &listen_error,
connection_id,
peer_id: None,
}));

self.pending_swarm_events
Expand Down

0 comments on commit b901215

Please sign in to comment.