diff --git a/src/index.ts b/src/index.ts index 9bc059a6..6162a13d 100644 --- a/src/index.ts +++ b/src/index.ts @@ -2036,6 +2036,18 @@ export class GossipSub extends TypedEventEmitter 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 }