(to revert) add some traces

This commit is contained in:
Giovanni Petrantoni 2020-09-14 15:23:21 +09:00
parent b6470707a8
commit 4663eaab6c
5 changed files with 12 additions and 0 deletions

View File

@ -10,6 +10,7 @@
## This module implements Public Key and Private Key interface for libp2p.
{.push raises: [Defect].}
from strutils import split, strip, cmpIgnoreCase
import chronicles
const libp2p_pki_schemes* {.strdefine.} = "rsa,ed25519,secp256k1,ecnist"
@ -1058,6 +1059,7 @@ proc getField*[T: PublicKey|PrivateKey](pb: ProtoBuffer, field: int,
value = key
ok(true)
else:
debug "incorrect blob", bt=getStackTrace()
err(ProtoError.IncorrectBlob)
proc getField*(pb: ProtoBuffer, field: int,
@ -1076,4 +1078,5 @@ proc getField*(pb: ProtoBuffer, field: int,
value = sig
ok(true)
else:
debug "incorrect blob", bt=getStackTrace()
err(ProtoError.IncorrectBlob)

View File

@ -18,6 +18,7 @@ import multicodec, multihash, multibase, transcoder, vbuffer, peerid,
protobuf/minprotobuf
import stew/[base58, base32, endians2, results]
export results, minprotobuf, vbuffer
import chronicles
type
MAKind* = enum
@ -1044,6 +1045,7 @@ proc getField*(pb: var ProtoBuffer, field: int,
value = ma.get()
ok(true)
else:
debug "incorrect blob", bt=getStackTrace()
err(ProtoError.IncorrectBlob)
proc getRepeatedField*(pb: var ProtoBuffer, field: int,
@ -1061,5 +1063,6 @@ proc getRepeatedField*(pb: var ProtoBuffer, field: int,
value.add(ma.get())
else:
value.setLen(0)
debug "incorrect blob", bt=getStackTrace()
return err(ProtoError.IncorrectBlob)
ok(true)

View File

@ -234,4 +234,5 @@ proc getField*(pb: ProtoBuffer, field: int,
pid = peerId
ok(true)
else:
debug "incorrect blob", bt=getStackTrace(), len=buffer.len
err(ProtoError.IncorrectBlob)

View File

@ -100,6 +100,7 @@ proc handle*(p: PubSubPeer, conn: Connection) {.async.} =
notice "failed to decode msg from peer",
conn, peer = p, closed = conn.closed,
err = rmsg.error()
trace "failed message", bytes=data.toHex()
break
trace "decoded msg from peer",

View File

@ -13,6 +13,7 @@ import messages,
../../../peerid,
../../../utility,
../../../protobuf/minprotobuf
import stew/byteutils
proc write*(pb: var ProtoBuffer, field: int, graft: ControlGraft) =
var ipb = initProtoBuffer()
@ -76,8 +77,11 @@ proc write*(pb: var ProtoBuffer, field: int, subs: SubOpts) =
proc encodeMessage*(msg: Message): seq[byte] =
var pb = initProtoBuffer()
pb.write(1, msg.fromPeer)
trace "encodeMessage: write fromPeer", fromPeer = msg.fromPeer
pb.write(2, msg.data)
trace "encodeMessage: write data", data = msg.data.toHex
pb.write(3, msg.seqno)
trace "encodeMessage: write seqno", seqno = msg.seqno
for topic in msg.topicIDs:
pb.write(4, topic)
if len(msg.signature) > 0: