Fix potential race condition

This commit is contained in:
Andrea Maria Piana 2021-01-26 16:56:06 +01:00
parent cec7c52505
commit e433e7d470
2 changed files with 2 additions and 2 deletions

View File

@ -595,9 +595,9 @@ func (w *Waku) notifyPeersAboutTopicInterestChange(topicInterest []common.TopicT
}
func (w *Waku) getPeers() []common.Peer {
w.peerMu.Lock()
arr := make([]common.Peer, len(w.peers))
i := 0
w.peerMu.Lock()
for p := range w.peers {
arr[i] = p
i++

View File

@ -459,9 +459,9 @@ func (whisper *Whisper) notifyPeersAboutBloomFilterChange(bloom []byte) {
}
func (whisper *Whisper) getPeers() []*Peer {
whisper.peerMu.Lock()
arr := make([]*Peer, len(whisper.peers))
i := 0
whisper.peerMu.Lock()
for p := range whisper.peers {
arr[i] = p
i++