Short agent fix (#645)

* Copy client type to muxed channel

* Fix incoming shortAgent
This commit is contained in:
Tanguy 2021-11-08 17:42:56 +01:00 committed by GitHub
parent c92125a1a4
commit 7d677f848f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 0 deletions

View File

@ -97,6 +97,8 @@ proc newStreamInternal*(m: Mplex,
result.peerId = m.connection.peerId result.peerId = m.connection.peerId
result.observedAddr = m.connection.observedAddr result.observedAddr = m.connection.observedAddr
result.transportDir = m.connection.transportDir 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 trace "Creating new channel", m, channel = result, id, initiator, name

View File

@ -173,6 +173,11 @@ proc muxerHandler(
try: try:
await self.identify(muxer) 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: except IdentifyError as exc:
# Identify is non-essential, though if it fails, it might indicate that # 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 # the connection was closed already - this will be picked up by the read