mirror of
https://github.com/status-im/status-go.git
synced 2025-01-10 22:56:40 +00:00
6cdea4ef97
* Update project to use Whisper v6. Part of #638 * Revert "Add patch to downgrade usage of Whisper v6 to v5 in some geth 1.8.1 vendor files. Part of #665" - this reverts commit 6aefb4c8fd02dbcfffac6b69e8bb22b13ef86b6b. * Enable light mode on Whisper v6 for non-mail servers. Part of #638 * Fix race condition in whisperv6/peer.go. Part of #665 (PR already accepted upstream for 1.8.2) * Update bootnode addresses in staticnodes.json. Part of #638 * Add `shh.lightclient` flag and tests for bloom filter setting logic. Part of #638 * Move MakeTestNodeConfig to utils. Part of #638 * Reduce PoW in `whisper_jail_test.go` to fix flaky test. Part of #638
36 lines
1003 B
Diff
36 lines
1003 B
Diff
diff --git a/whisper/whisperv6/peer.go b/whisper/whisperv6/peer.go
|
|
index 4ef0f3c4..6a7ab358 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"
|
|
@@ -38,6 +39,7 @@ type Peer struct {
|
|
powRequirement float64
|
|
+ bloomMu sync.Mutex
|
|
bloomFilter []byte
|
|
fullNode bool
|
|
|
|
known *set.Set // Messages already known by the peer to avoid wasting bandwidth
|
|
|
|
@@ -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 {
|