Merge pull request #196 from libp2p/fix/minor-bug

minor bug fix: on join, source peers from gossip[topic] if insufficient peers in fanout[topic]
This commit is contained in:
vyzo 2019-10-05 21:58:11 +03:00 committed by GitHub
commit 55553ac009
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 0 deletions

View File

@ -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)