diff --git a/Cargo.lock b/Cargo.lock index a811dcc6de9..f5ebfaeb1f9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3191,7 +3191,7 @@ dependencies = [ [[package]] name = "libp2p-relay" -version = "0.19.0" +version = "0.19.1" dependencies = [ "asynchronous-codec", "bytes", diff --git a/Cargo.toml b/Cargo.toml index 4b92b086326..72373a564a1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -94,7 +94,7 @@ libp2p-ping = { version = "0.46.0", path = "protocols/ping" } libp2p-plaintext = { version = "0.43.0", path = "transports/plaintext" } libp2p-pnet = { version = "0.26.0", path = "transports/pnet" } libp2p-quic = { version = "0.12.0", path = "transports/quic" } -libp2p-relay = { version = "0.19.0", path = "protocols/relay" } +libp2p-relay = { version = "0.19.1", path = "protocols/relay" } libp2p-rendezvous = { version = "0.16.0", path = "protocols/rendezvous" } libp2p-request-response = { version = "0.28.0", path = "protocols/request-response" } libp2p-server = { version = "0.12.6", path = "misc/server" } diff --git a/protocols/relay/CHANGELOG.md b/protocols/relay/CHANGELOG.md index e60dcfb7596..549c545c036 100644 --- a/protocols/relay/CHANGELOG.md +++ b/protocols/relay/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.19.1 + +- Remove duplicated forwarding of pending events to connection handler. + ## 0.19.0 - Deprecate `void` crate. diff --git a/protocols/relay/Cargo.toml b/protocols/relay/Cargo.toml index 23715fc86de..bd34fa7ee34 100644 --- a/protocols/relay/Cargo.toml +++ b/protocols/relay/Cargo.toml @@ -3,7 +3,7 @@ name = "libp2p-relay" edition = "2021" rust-version = { workspace = true } description = "Communications relaying for libp2p" -version = "0.19.0" +version = "0.19.1" authors = ["Parity Technologies ", "Max Inden "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" diff --git a/protocols/relay/src/priv_client.rs b/protocols/relay/src/priv_client.rs index 7ac9b716700..b8be01a2ea0 100644 --- a/protocols/relay/src/priv_client.rs +++ b/protocols/relay/src/priv_client.rs @@ -168,12 +168,14 @@ impl NetworkBehaviour for Behaviour { local_addr: &Multiaddr, remote_addr: &Multiaddr, ) -> Result, ConnectionDenied> { + let pending_handler_command = self.pending_handler_commands.remove(&connection_id); + if local_addr.is_relayed() { return Ok(Either::Right(dummy::ConnectionHandler)); } let mut handler = Handler::new(self.local_peer_id, peer, remote_addr.clone()); - if let Some(event) = self.pending_handler_commands.remove(&connection_id) { + if let Some(event) = pending_handler_command { handler.on_behaviour_event(event) } @@ -188,13 +190,15 @@ impl NetworkBehaviour for Behaviour { _: Endpoint, _: PortUse, ) -> Result, ConnectionDenied> { + let pending_handler_command = self.pending_handler_commands.remove(&connection_id); + if addr.is_relayed() { return Ok(Either::Right(dummy::ConnectionHandler)); } let mut handler = Handler::new(self.local_peer_id, peer, addr.clone()); - if let Some(event) = self.pending_handler_commands.remove(&connection_id) { + if let Some(event) = pending_handler_command { handler.on_behaviour_event(event) } @@ -208,21 +212,11 @@ impl NetworkBehaviour for Behaviour { connection_id, endpoint, .. - }) => { - if !endpoint.is_relayed() { - self.directly_connected_peers - .entry(peer_id) - .or_default() - .push(connection_id); - } - - if let Some(event) = self.pending_handler_commands.remove(&connection_id) { - self.queued_actions.push_back(ToSwarm::NotifyHandler { - peer_id, - handler: NotifyHandler::One(connection_id), - event: Either::Left(event), - }) - } + }) if !endpoint.is_relayed() => { + self.directly_connected_peers + .entry(peer_id) + .or_default() + .push(connection_id); } FromSwarm::ConnectionClosed(connection_closed) => { self.on_connection_closed(connection_closed)