aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuillaume Ballet <gballet@gmail.com>2018-02-23 18:49:47 +0800
committerGitHub <noreply@github.com>2018-02-23 18:49:47 +0800
commitfb5d085234c16f18d27be10043c53da3230cd9a7 (patch)
tree8deb1fd41efea7a202112aa747f2865f5df58eec
parent44d40ffce1200ce8875e187b57ac17e4901db32a (diff)
parent34d94e22d9c9f3c2373a398269ecbba0139827d2 (diff)
downloaddexon-fb5d085234c16f18d27be10043c53da3230cd9a7.tar
dexon-fb5d085234c16f18d27be10043c53da3230cd9a7.tar.gz
dexon-fb5d085234c16f18d27be10043c53da3230cd9a7.tar.bz2
dexon-fb5d085234c16f18d27be10043c53da3230cd9a7.tar.lz
dexon-fb5d085234c16f18d27be10043c53da3230cd9a7.tar.xz
dexon-fb5d085234c16f18d27be10043c53da3230cd9a7.tar.zst
dexon-fb5d085234c16f18d27be10043c53da3230cd9a7.zip
Merge pull request #16146 from status-im/pombeirp/whisperv6-peer-race-cond-fix
Fix race condition in whisperv6/peer.go
-rw-r--r--whisper/whisperv6/peer.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/whisper/whisperv6/peer.go b/whisper/whisperv6/peer.go
index 4ef0f3c43..6d75290fd 100644
--- a/whisper/whisperv6/peer.go
+++ b/whisper/whisperv6/peer.go
@@ -19,6 +19,7 @@ package whisperv6
import (
"fmt"
"math"
+ "sync"
"time"
"github.com/ethereum/go-ethereum/common"
@@ -36,6 +37,7 @@ type Peer struct {
trusted bool
powRequirement float64
+ bloomMu sync.Mutex
bloomFilter []byte
fullNode bool
@@ -225,10 +227,14 @@ func (peer *Peer) notifyAboutBloomFilterChange(bloom []byte) error {
}
func (peer *Peer) bloomMatch(env *Envelope) bool {
+ peer.bloomMu.Lock()
+ defer peer.bloomMu.Unlock()
return peer.fullNode || bloomFilterMatch(peer.bloomFilter, env.Bloom())
}
func (peer *Peer) setBloomFilter(bloom []byte) {
+ peer.bloomMu.Lock()
+ defer peer.bloomMu.Unlock()
peer.bloomFilter = bloom
peer.fullNode = isFullNode(bloom)
if peer.fullNode && peer.bloomFilter == nil {