Skip to content

Commit 954692f

Browse files
committed
fix empty map check
1 parent 1fcc15a commit 954692f

1 file changed

Lines changed: 5 additions & 8 deletions

File tree

gossipsub.go

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1388,9 +1388,10 @@ func (gs *GossipSubRouter) rpcs(msg *Message) iter.Seq2[peer.ID, *RPC] {
13881388
}
13891389

13901390
// gossipsub peers
1391-
gmap, ok := gs.mesh[topic]
1392-
if !ok || len(gmap) == 0 {
1393-
// we are not in the mesh for topic, use fanout peers
1391+
gmap := gs.mesh[topic]
1392+
if len(gmap) == 0 {
1393+
// we are not in the mesh for topic or our mesh is empty
1394+
// use fanout peers for publishing
13941395
gmap = gs.getFanoutPeersForPublishing(topic)
13951396
}
13961397

@@ -1489,11 +1490,7 @@ func (gs *GossipSubRouter) Join(topic string) {
14891490
return !direct && !doBackOff && gs.score.Score(p) >= 0
14901491
})
14911492
gmap = peerListToMap(peers)
1492-
// It is possible that we do not have any peers subscribed to this topic yet so continue fanout
1493-
// to ensure that messages we publish in the intermin are not lost
1494-
if len(gmap) > 0 {
1495-
gs.mesh[topic] = gmap
1496-
}
1493+
gs.mesh[topic] = gmap
14971494
}
14981495

14991496
for p := range gmap {

0 commit comments

Comments
 (0)