Skip to content

Commit

Permalink
include connection info when logging identify message (#991)
Browse files Browse the repository at this point in the history
  • Loading branch information
etan-status authored and romanzac committed Dec 13, 2023
1 parent 5702b2d commit 762be89
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions libp2p/protocols/identify.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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*(
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 762be89

Please sign in to comment.