From 4f4ba50c13e44a6c425195659e8c060bf3dc6b7a Mon Sep 17 00:00:00 2001 From: Alexandru Vasile Date: Wed, 23 Oct 2024 16:41:46 +0300 Subject: [PATCH] identify: Fix memory leak of unused `pending_opens` Signed-off-by: Alexandru Vasile --- src/protocol/libp2p/identify.rs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/protocol/libp2p/identify.rs b/src/protocol/libp2p/identify.rs index 1c0a5985..e8fa4f50 100644 --- a/src/protocol/libp2p/identify.rs +++ b/src/protocol/libp2p/identify.rs @@ -180,9 +180,6 @@ pub(crate) struct Identify { /// Protocols supported by the local node, filled by `Litep2p`. protocols: Vec, - /// Pending outbound substreams. - pending_opens: HashMap, - /// Pending outbound substreams. pending_outbound: FuturesUnordered>>, @@ -200,7 +197,6 @@ impl Identify { public: config.public.expect("public key to be supplied"), protocol_version: config.protocol_version, user_agent: config.user_agent.unwrap_or(DEFAULT_AGENT.to_string()), - pending_opens: HashMap::new(), pending_inbound: FuturesUnordered::new(), pending_outbound: FuturesUnordered::new(), protocols: config.protocols.iter().map(|protocol| protocol.to_string()).collect(), @@ -211,8 +207,7 @@ impl Identify { fn on_connection_established(&mut self, peer: PeerId, endpoint: Endpoint) -> crate::Result<()> { tracing::trace!(target: LOG_TARGET, ?peer, ?endpoint, "connection established"); - let substream_id = self.service.open_substream(peer)?; - self.pending_opens.insert(substream_id, peer); + self.service.open_substream(peer)?; self.peers.insert(peer, endpoint); Ok(())