mirror of https://github.com/vacp2p/nim-libp2p.git
fix validation according to specification (#410)
This commit is contained in:
parent
5c19668b2d
commit
27b9bf436e
|
@ -85,9 +85,13 @@ method rpcHandler*(f: FloodSub,
|
|||
# g.anonymize needs no evaluation when receiving messages
|
||||
# as we have a "lax" policy and allow signed messages
|
||||
|
||||
if (await f.validate(msg)) == ValidationResult.Reject:
|
||||
trace "Dropping message due to failed validation", msgId, peer
|
||||
let validation = await f.validate(msg)
|
||||
case validation
|
||||
of ValidationResult.Reject, ValidationResult.Ignore:
|
||||
debug "Dropping message due to ignored validation", msgId, peer
|
||||
continue
|
||||
of ValidationResult.Accept:
|
||||
discard
|
||||
|
||||
var toSendPeers = initHashSet[PubSubPeer]()
|
||||
for t in msg.topicIDs: # for every topic in the message
|
||||
|
|
|
@ -1062,10 +1062,17 @@ method rpcHandler*(g: GossipSub,
|
|||
# g.anonymize needs no evaluation when receiving messages
|
||||
# as we have a "lax" policy and allow signed messages
|
||||
|
||||
if (await g.validate(msg)) == ValidationResult.Reject:
|
||||
let validation = await g.validate(msg)
|
||||
case validation
|
||||
of ValidationResult.Reject:
|
||||
debug "Dropping message due to failed validation", msgId, peer
|
||||
g.punishPeer(peer, msg)
|
||||
continue
|
||||
of ValidationResult.Ignore:
|
||||
debug "Dropping message due to ignored validation", msgId, peer
|
||||
continue
|
||||
of ValidationResult.Accept:
|
||||
discard
|
||||
|
||||
var toSendPeers = initHashSet[PubSubPeer]()
|
||||
for t in msg.topicIDs: # for every topic in the message
|
||||
|
|
|
@ -464,9 +464,13 @@ method rpcHandler*(g: GossipSub,
|
|||
# g.anonymize needs no evaluation when receiving messages
|
||||
# as we have a "lax" policy and allow signed messages
|
||||
|
||||
if (await g.validate(msg)) == ValidationResult.Reject:
|
||||
trace "Dropping message due to failed validation", msgId, peer
|
||||
let validation = await g.validate(msg)
|
||||
case validation
|
||||
of ValidationResult.Reject, ValidationResult.Ignore:
|
||||
debug "Dropping message due to ignored validation", msgId, peer
|
||||
continue
|
||||
of ValidationResult.Accept:
|
||||
discard
|
||||
|
||||
var toSendPeers = initHashSet[PubSubPeer]()
|
||||
for t in msg.topicIDs: # for every topic in the message
|
||||
|
|
Loading…
Reference in New Issue