event, whisper/whisperv6: use defer where possible (#20940)
This commit is contained in:
parent
9887edd580
commit
0708b573bc
@ -196,9 +196,9 @@ func (s *TypeMuxSubscription) closewait() {
|
|||||||
s.closed = true
|
s.closed = true
|
||||||
|
|
||||||
s.postMu.Lock()
|
s.postMu.Lock()
|
||||||
|
defer s.postMu.Unlock()
|
||||||
close(s.postC)
|
close(s.postC)
|
||||||
s.postC = nil
|
s.postC = nil
|
||||||
s.postMu.Unlock()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *TypeMuxSubscription) deliver(event *TypeMuxEvent) {
|
func (s *TypeMuxSubscription) deliver(event *TypeMuxEvent) {
|
||||||
|
@ -340,11 +340,11 @@ func (whisper *Whisper) getPeers() []*Peer {
|
|||||||
arr := make([]*Peer, len(whisper.peers))
|
arr := make([]*Peer, len(whisper.peers))
|
||||||
i := 0
|
i := 0
|
||||||
whisper.peerMu.Lock()
|
whisper.peerMu.Lock()
|
||||||
|
defer whisper.peerMu.Unlock()
|
||||||
for p := range whisper.peers {
|
for p := range whisper.peers {
|
||||||
arr[i] = p
|
arr[i] = p
|
||||||
i++
|
i++
|
||||||
}
|
}
|
||||||
whisper.peerMu.Unlock()
|
|
||||||
return arr
|
return arr
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user