Skip to content

Commit

Permalink
fix: opportunistic graft (#257)
Browse files Browse the repository at this point in the history
* fix: opportunistic graft

* fix: lint
  • Loading branch information
twoeths committed Jun 3, 2022
1 parent e84a7fd commit 035314c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2465,7 +2465,9 @@ export class GossipSub extends EventEmitter<GossipsubEvents> implements Initiali
const backoff = this.backoff.get(topic)
const peersToGraft = this.getRandomGossipPeers(topic, this.opts.opportunisticGraftPeers, (id) => {
// filter out current mesh peers, direct peers, peers we are backing off, peers below or at threshold
return peers.has(id) && !this.direct.has(id) && (!backoff || !backoff.has(id)) && getScore(id) > medianScore
return (
!peers.has(id) && !this.direct.has(id) && (!backoff || !backoff.has(id)) && getScore(id) > medianScore
)
})
peersToGraft.forEach((id) => {
this.log('HEARTBEAT: Opportunistically graft peer %s on topic %s', id, topic)
Expand Down

0 comments on commit 035314c

Please sign in to comment.