don't increase seqno when anonymizing (#734)

This commit is contained in:
Jacek Sieka 2022-06-30 09:56:49 +02:00 committed by GitHub
parent 5d7024f2e0
commit 597abddba7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 20 deletions

View File

@ -187,21 +187,17 @@ method publish*(f: FloodSub,
debug "No peers for topic, skipping publish", topic debug "No peers for topic, skipping publish", topic
return 0 return 0
inc f.msgSeqno
let let
msg = msg =
if f.anonymize: if f.anonymize:
Message.init(none(PeerInfo), data, topic, none(uint64), false) Message.init(none(PeerInfo), data, topic, none(uint64), false)
else: else:
inc f.msgSeqno
Message.init(some(f.peerInfo), data, topic, some(f.msgSeqno), f.sign) Message.init(some(f.peerInfo), data, topic, some(f.msgSeqno), f.sign)
msgIdResult = f.msgIdProvider(msg) msgId = f.msgIdProvider(msg).valueOr:
trace "Error generating message id, skipping publish",
if msgIdResult.isErr: error = error
trace "Error generating message id, skipping publish", return 0
error = msgIdResult.error
return 0
let msgId = msgIdResult.get
trace "Created new message", trace "Created new message",
msg = shortLog(msg), peers = peers.len, topic, msgId msg = shortLog(msg), peers = peers.len, topic, msgId

View File

@ -506,7 +506,7 @@ method publish*(g: GossipSub,
g.rng.shuffle(fanoutPeers) g.rng.shuffle(fanoutPeers)
if fanoutPeers.len + peers.len > g.parameters.d: if fanoutPeers.len + peers.len > g.parameters.d:
fanoutPeers.setLen(g.parameters.d - peers.len) fanoutPeers.setLen(g.parameters.d - peers.len)
for fanPeer in fanoutPeers: for fanPeer in fanoutPeers:
peers.incl(fanPeer) peers.incl(fanPeer)
if peers.len > g.parameters.d: break if peers.len > g.parameters.d: break
@ -527,22 +527,18 @@ method publish*(g: GossipSub,
libp2p_gossipsub_failed_publish.inc() libp2p_gossipsub_failed_publish.inc()
return 0 return 0
inc g.msgSeqno
let let
msg = msg =
if g.anonymize: if g.anonymize:
Message.init(none(PeerInfo), data, topic, none(uint64), false) Message.init(none(PeerInfo), data, topic, none(uint64), false)
else: else:
inc g.msgSeqno
Message.init(some(g.peerInfo), data, topic, some(g.msgSeqno), g.sign) Message.init(some(g.peerInfo), data, topic, some(g.msgSeqno), g.sign)
msgIdResult = g.msgIdProvider(msg) msgId = g.msgIdProvider(msg).valueOr:
trace "Error generating message id, skipping publish",
if msgIdResult.isErr: error = error
trace "Error generating message id, skipping publish", libp2p_gossipsub_failed_publish.inc()
error = msgIdResult.error return 0
libp2p_gossipsub_failed_publish.inc()
return 0
let msgId = msgIdResult.get
logScope: msgId = shortLog(msgId) logScope: msgId = shortLog(msgId)