Skip to content

Commit

Permalink
feat(swarm): remove handler field from ConnectionClosed event
Browse files Browse the repository at this point in the history
Instead of transferring the `ConnectionHandler` back in a event to the `NetworkBehaviour`, we introduce `ConnectionHandler::poll_close`. This function will be polled like a `Stream` and can emit events that will be delivered to the `NetworkBehaviour`.

Resolves: libp2p#3046.

Pull-Request: libp2p#4076.
  • Loading branch information
thomaseizinger authored Oct 26, 2023
1 parent d424d03 commit eb0c66f
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -362,16 +362,14 @@ impl Behaviour {
peer_id,
connection_id,
endpoint,
handler,
remaining_established,
}: ConnectionClosed<<Self as NetworkBehaviour>::ConnectionHandler>,
}: ConnectionClosed,
) {
self.inner
.on_swarm_event(FromSwarm::ConnectionClosed(ConnectionClosed {
peer_id,
connection_id,
endpoint,
handler,
remaining_established,
}));

Expand Down Expand Up @@ -539,7 +537,7 @@ impl NetworkBehaviour for Behaviour {
.handle_established_outbound_connection(connection_id, peer, addr, role_override)
}

fn on_swarm_event(&mut self, event: FromSwarm<Self::ConnectionHandler>) {
fn on_swarm_event(&mut self, event: FromSwarm) {
self.listen_addresses.on_swarm_event(&event);

match event {
Expand Down

0 comments on commit eb0c66f

Please sign in to comment.