From 762be89dd7c6d96696091da5284207d92540a027 Mon Sep 17 00:00:00 2001 From: Etan Kissling Date: Tue, 5 Dec 2023 18:44:16 +0100 Subject: [PATCH] include connection info when logging identify message (#991) --- libp2p/protocols/identify.nim | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libp2p/protocols/identify.nim b/libp2p/protocols/identify.nim index 1b86d5928d..3a1f6f925c 100644 --- a/libp2p/protocols/identify.nim +++ b/libp2p/protocols/identify.nim @@ -78,7 +78,7 @@ chronicles.expandIt(IdentifyInfo): signedPeerRecord = # The SPR contains the same data as the identify message # would be cumbersome to log - if iinfo.signedPeerRecord.isSome(): "Some" + if it.signedPeerRecord.isSome(): "Some" else: "None" proc encodeMsg(peerInfo: PeerInfo, observedAddr: Opt[MultiAddress], sendSpr: bool): ProtoBuffer @@ -134,7 +134,6 @@ proc decodeMsg*(buf: seq[byte]): Opt[IdentifyInfo] = if ? pb.getField(6, agentVersion).toOpt(): iinfo.agentVersion = some(agentVersion) - debug "decodeMsg: decoded identify", iinfo Opt.some(iinfo) proc new*( @@ -178,6 +177,7 @@ proc identify*(self: Identify, raise newException(IdentityInvalidMsgError, "Empty message received!") var info = decodeMsg(message).valueOr: raise newException(IdentityInvalidMsgError, "Incorrect message received!") + debug "identify: decoded message", conn, info let pubkey = info.pubkey.valueOr: raise newException(IdentityInvalidMsgError, "No pubkey in identify") peer = PeerId.init(pubkey).valueOr: raise newException(IdentityInvalidMsgError, $error) @@ -211,6 +211,7 @@ proc init*(p: IdentifyPush) = var identInfo = decodeMsg(message).valueOr: raise newException(IdentityInvalidMsgError, "Incorrect message received!") + debug "identify push: decoded message", conn, identInfo identInfo.pubkey.withValue(pubkey): let receivedPeerId = PeerId.init(pubkey).tryGet()