nice msgid log formatting (#491)
This commit is contained in:
parent
52628d1a2e
commit
a1a5f9abac
|
@ -914,14 +914,14 @@ method subscribeTopic*(g: GossipSub,
|
||||||
peer
|
peer
|
||||||
topic
|
topic
|
||||||
|
|
||||||
# this is a workaround for a race condition
|
# this is a workaround for a race condition
|
||||||
# that can happen if we disconnect the peer very early
|
# that can happen if we disconnect the peer very early
|
||||||
# in the future we might use this as a test case
|
# in the future we might use this as a test case
|
||||||
# and eventually remove this workaround
|
# and eventually remove this workaround
|
||||||
if subscribe and peer.peerId notin g.peers:
|
if subscribe and peer.peerId notin g.peers:
|
||||||
trace "ignoring unknown peer"
|
trace "ignoring unknown peer"
|
||||||
return
|
return
|
||||||
|
|
||||||
# Skip floodsub - we don't want it to add the peer to `g.floodsub`
|
# Skip floodsub - we don't want it to add the peer to `g.floodsub`
|
||||||
procCall PubSub(g).subscribeTopic(topic, subscribe, peer)
|
procCall PubSub(g).subscribeTopic(topic, subscribe, peer)
|
||||||
|
|
||||||
|
@ -1126,7 +1126,7 @@ method rpcHandler*(g: GossipSub,
|
||||||
let msgId = g.msgIdProvider(msg)
|
let msgId = g.msgIdProvider(msg)
|
||||||
|
|
||||||
if g.seen.put(msgId):
|
if g.seen.put(msgId):
|
||||||
trace "Dropping already-seen message", msgId, peer
|
trace "Dropping already-seen message", msgId = shortLog(msgId), peer
|
||||||
|
|
||||||
# make sure to update score tho before continuing
|
# make sure to update score tho before continuing
|
||||||
for t in msg.topicIDs: # for every topic in the message
|
for t in msg.topicIDs: # for every topic in the message
|
||||||
|
@ -1154,13 +1154,15 @@ method rpcHandler*(g: GossipSub,
|
||||||
|
|
||||||
if (msg.signature.len > 0 or g.verifySignature) and not msg.verify():
|
if (msg.signature.len > 0 or g.verifySignature) and not msg.verify():
|
||||||
# always validate if signature is present or required
|
# always validate if signature is present or required
|
||||||
debug "Dropping message due to failed signature verification", msgId, peer
|
debug "Dropping message due to failed signature verification",
|
||||||
|
msgId = shortLog(msgId), peer
|
||||||
g.punishPeer(peer, msg.topicIDs)
|
g.punishPeer(peer, msg.topicIDs)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if msg.seqno.len > 0 and msg.seqno.len != 8:
|
if msg.seqno.len > 0 and msg.seqno.len != 8:
|
||||||
# if we have seqno should be 8 bytes long
|
# if we have seqno should be 8 bytes long
|
||||||
debug "Dropping message due to invalid seqno length", msgId, peer
|
debug "Dropping message due to invalid seqno length",
|
||||||
|
msgId = shortLog(msgId), peer
|
||||||
g.punishPeer(peer, msg.topicIDs)
|
g.punishPeer(peer, msg.topicIDs)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
@ -1170,11 +1172,13 @@ method rpcHandler*(g: GossipSub,
|
||||||
let validation = await g.validate(msg)
|
let validation = await g.validate(msg)
|
||||||
case validation
|
case validation
|
||||||
of ValidationResult.Reject:
|
of ValidationResult.Reject:
|
||||||
debug "Dropping message after validation, reason: reject", msgId, peer
|
debug "Dropping message after validation, reason: reject",
|
||||||
|
msgId = shortLog(msgId), peer
|
||||||
g.punishPeer(peer, msg.topicIDs)
|
g.punishPeer(peer, msg.topicIDs)
|
||||||
continue
|
continue
|
||||||
of ValidationResult.Ignore:
|
of ValidationResult.Ignore:
|
||||||
debug "Dropping message after validation, reason: ignore", msgId, peer
|
debug "Dropping message after validation, reason: ignore",
|
||||||
|
msgId = shortLog(msgId), peer
|
||||||
continue
|
continue
|
||||||
of ValidationResult.Accept:
|
of ValidationResult.Accept:
|
||||||
discard
|
discard
|
||||||
|
@ -1215,7 +1219,8 @@ method rpcHandler*(g: GossipSub,
|
||||||
# In theory, if topics are the same in all messages, we could batch - we'd
|
# In theory, if topics are the same in all messages, we could batch - we'd
|
||||||
# also have to be careful to only include validated messages
|
# also have to be careful to only include validated messages
|
||||||
g.broadcast(toSeq(toSendPeers), RPCMsg(messages: @[msg]))
|
g.broadcast(toSeq(toSendPeers), RPCMsg(messages: @[msg]))
|
||||||
trace "forwared message to peers", peers = toSendPeers.len, msgId, peer
|
trace "forwared message to peers", peers = toSendPeers.len,
|
||||||
|
msgId = shortLog(msgId), peer
|
||||||
libp2p_pubsub_messages_rebroadcasted.inc()
|
libp2p_pubsub_messages_rebroadcasted.inc()
|
||||||
|
|
||||||
if rpcMsg.control.isSome:
|
if rpcMsg.control.isSome:
|
||||||
|
@ -1339,7 +1344,7 @@ method publish*(g: GossipSub,
|
||||||
Message.init(some(g.peerInfo), data, topic, some(g.msgSeqno), g.sign)
|
Message.init(some(g.peerInfo), data, topic, some(g.msgSeqno), g.sign)
|
||||||
msgId = g.msgIdProvider(msg)
|
msgId = g.msgIdProvider(msg)
|
||||||
|
|
||||||
logScope: msgId
|
logScope: msgId = shortLog(msgId)
|
||||||
|
|
||||||
trace "Created new message", msg = shortLog(msg), peers = peers.len
|
trace "Created new message", msg = shortLog(msg), peers = peers.len
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue