From 5d1b10f3e7db77ad87319f63aa43295770196f87 Mon Sep 17 00:00:00 2001 From: Tanguy Date: Mon, 8 Nov 2021 17:42:56 +0100 Subject: [PATCH] Short agent fix (#645) * Copy client type to muxed channel * Fix incoming shortAgent --- libp2p/muxers/mplex/mplex.nim | 2 ++ libp2p/upgrademngrs/muxedupgrade.nim | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/libp2p/muxers/mplex/mplex.nim b/libp2p/muxers/mplex/mplex.nim index d84cf5e00..7d75942e4 100644 --- a/libp2p/muxers/mplex/mplex.nim +++ b/libp2p/muxers/mplex/mplex.nim @@ -97,6 +97,8 @@ proc newStreamInternal*(m: Mplex, result.peerId = m.connection.peerId result.observedAddr = m.connection.observedAddr result.transportDir = m.connection.transportDir + when defined(libp2p_agents_metrics): + result.shortAgent = m.connection.shortAgent trace "Creating new channel", m, channel = result, id, initiator, name diff --git a/libp2p/upgrademngrs/muxedupgrade.nim b/libp2p/upgrademngrs/muxedupgrade.nim index 2ba98c875..fc596a704 100644 --- a/libp2p/upgrademngrs/muxedupgrade.nim +++ b/libp2p/upgrademngrs/muxedupgrade.nim @@ -173,6 +173,11 @@ proc muxerHandler( try: await self.identify(muxer) + when defined(libp2p_agents_metrics): + #TODO Passing data between layers is a pain + if muxer.connection of SecureConn: + let secureConn = (SecureConn)muxer.connection + secureConn.stream.shortAgent = muxer.connection.shortAgent except IdentifyError as exc: # Identify is non-essential, though if it fails, it might indicate that # the connection was closed already - this will be picked up by the read