diff --git a/libp2p/protocols/pubsub/gossipsub/behavior.nim b/libp2p/protocols/pubsub/gossipsub/behavior.nim index 57ea160..bbdcd27 100644 --- a/libp2p/protocols/pubsub/gossipsub/behavior.nim +++ b/libp2p/protocols/pubsub/gossipsub/behavior.nim @@ -130,6 +130,10 @@ proc handleGraft*(g: GossipSub, continue + if g.mesh.hasPeer(topic, peer): + trace "peer already in mesh", peer, topic + continue + # Check backingOff # Ignore BackoffSlackTime here, since this only for outbound activity # and subtract a second time to avoid race conditions @@ -176,6 +180,10 @@ proc handleGraft*(g: GossipSub, topicID: topic, peers: g.peerExchangeList(topic), backoff: g.parameters.pruneBackoff.seconds.uint64)) + + let backoff = Moment.fromNow(g.parameters.pruneBackoff) + g.backingOff + .mgetOrPut(topic, initTable[PeerId, Moment]())[peer.peerId] = backoff else: trace "peer grafting topic we're not interested in", peer, topic # gossip 1.1, we do not send a control message prune anymore diff --git a/libp2p/protocols/pubsub/gossipsub/scoring.nim b/libp2p/protocols/pubsub/gossipsub/scoring.nim index b107e8f..fdc34cc 100644 --- a/libp2p/protocols/pubsub/gossipsub/scoring.nim +++ b/libp2p/protocols/pubsub/gossipsub/scoring.nim @@ -295,11 +295,11 @@ proc rewardDelivered*( g.withPeerStats(peer.peerId) do (stats: var PeerStats): stats.topicInfos.withValue(tt, tstats): - if tstats[].inMesh: - if first: - tstats[].firstMessageDeliveries.addCapped( - 1, topicParams.firstMessageDeliveriesCap) + if first: + tstats[].firstMessageDeliveries.addCapped( + 1, topicParams.firstMessageDeliveriesCap) + if tstats[].inMesh: tstats[].meshMessageDeliveries.addCapped( 1, topicParams.meshMessageDeliveriesCap) do: # make sure we don't loose this information