Skip to content

Commit

Permalink
fix: concurrent peerMap iteration and write
Browse files Browse the repository at this point in the history
  • Loading branch information
qfrank committed Dec 12, 2024
1 parent 9a24369 commit 4848017
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions waku/v2/peermanager/peer_selection.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ func (pm *PeerManager) selectServicePeer(criteria PeerSelectionCriteria) (PeerSe
if len(criteria.PubsubTopics) == 0 || (len(criteria.PubsubTopics) == 1 && criteria.PubsubTopics[0] == "") {
return slot.getRandom(criteria.MaxPeers, criteria.ExcludePeers)
} else { //PubsubTopic based selection
slot.mu.RLock()
defer slot.mu.RUnlock()
keys := make([]peer.ID, 0, len(slot.m))
for i := range slot.m {
if PeerInSet(criteria.ExcludePeers, i) {
Expand Down

0 comments on commit 4848017

Please sign in to comment.