Various gossipsub fixes (#827)

This commit is contained in:
Tanguy 2023-03-21 17:13:25 +01:00 committed by GitHub
parent 8d5ea43e2b
commit bac754e2ad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 4 deletions

View File

@ -130,6 +130,10 @@ proc handleGraft*(g: GossipSub,
continue continue
if g.mesh.hasPeer(topic, peer):
trace "peer already in mesh", peer, topic
continue
# Check backingOff # Check backingOff
# Ignore BackoffSlackTime here, since this only for outbound activity # Ignore BackoffSlackTime here, since this only for outbound activity
# and subtract a second time to avoid race conditions # and subtract a second time to avoid race conditions
@ -176,6 +180,10 @@ proc handleGraft*(g: GossipSub,
topicID: topic, topicID: topic,
peers: g.peerExchangeList(topic), peers: g.peerExchangeList(topic),
backoff: g.parameters.pruneBackoff.seconds.uint64)) backoff: g.parameters.pruneBackoff.seconds.uint64))
let backoff = Moment.fromNow(g.parameters.pruneBackoff)
g.backingOff
.mgetOrPut(topic, initTable[PeerId, Moment]())[peer.peerId] = backoff
else: else:
trace "peer grafting topic we're not interested in", peer, topic trace "peer grafting topic we're not interested in", peer, topic
# gossip 1.1, we do not send a control message prune anymore # gossip 1.1, we do not send a control message prune anymore

View File

@ -295,11 +295,11 @@ proc rewardDelivered*(
g.withPeerStats(peer.peerId) do (stats: var PeerStats): g.withPeerStats(peer.peerId) do (stats: var PeerStats):
stats.topicInfos.withValue(tt, tstats): stats.topicInfos.withValue(tt, tstats):
if tstats[].inMesh: if first:
if first: tstats[].firstMessageDeliveries.addCapped(
tstats[].firstMessageDeliveries.addCapped( 1, topicParams.firstMessageDeliveriesCap)
1, topicParams.firstMessageDeliveriesCap)
if tstats[].inMesh:
tstats[].meshMessageDeliveries.addCapped( tstats[].meshMessageDeliveries.addCapped(
1, topicParams.meshMessageDeliveriesCap) 1, topicParams.meshMessageDeliveriesCap)
do: # make sure we don't loose this information do: # make sure we don't loose this information