Skip to content

Commit

Permalink
feat: publish at least mesh_n peers
Browse files Browse the repository at this point in the history
  • Loading branch information
twoeths committed Mar 27, 2024
1 parent ff620fd commit 14a6c32
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2036,6 +2036,18 @@ export class GossipSub extends TypedEventEmitter<GossipsubEvents> implements Pub
tosend.add(peer)
tosendCount.mesh++
})

if (meshPeers.size < this.opts.D) {
// pick additional topic peers above the publishThreshold
const topicPeers = this.getRandomGossipPeers(topic, this.opts.D - meshPeers.size, (id) => {
return !meshPeers.has(id) && !this.direct.has(id) && !this.floodsubPeers.has(id) && this.score.score(id) >= this.opts.scoreThresholds.publishThreshold
})

topicPeers.forEach((peer) => {
tosend.add(peer)
tosendCount.mesh++
})
}
// eslint-disable-next-line @typescript-eslint/brace-style
}

Expand Down

0 comments on commit 14a6c32

Please sign in to comment.