From 7d677f848ff862214806a25333f0e23fe45c8110 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 efa6013..d6eda76 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 f600880..e92e5d3 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