Skip to content

Commit

Permalink
Merge pull request #196 from libp2p/fix/minor-bug
Browse files Browse the repository at this point in the history
minor bug fix: on join, source peers from gossip[topic] if insufficient peers in fanout[topic]
  • Loading branch information
vyzo committed Oct 5, 2019
2 parents dba8299 + 2bac470 commit 55553ac
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions gossipsub.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,17 @@ func (gs *GossipSubRouter) Join(topic string) {

gmap, ok = gs.fanout[topic]
if ok {
if len(gmap) < GossipSubD {
// we need more peers; eager, as this would get fixed in the next heartbeat
more := gs.getPeers(topic, GossipSubD-len(gmap), func(p peer.ID) bool {
// filter our current peers
_, ok := gmap[p]
return !ok
})
for _, p := range more {
gmap[p] = struct{}{}
}
}
gs.mesh[topic] = gmap
delete(gs.fanout, topic)
delete(gs.lastpub, topic)
Expand Down

0 comments on commit 55553ac

Please sign in to comment.