aboutsummaryrefslogtreecommitdiffstats
path: root/whisper/whisperv6
diff options
context:
space:
mode:
authorRalph Caraveo III <deckarep@gmail.com>2018-07-16 15:54:19 +0800
committerPéter Szilágyi <peterke@gmail.com>2018-07-16 15:54:19 +0800
commit5d30be412b0f9181cb007c8893ee583ee4319116 (patch)
tree4593b259665d22c552cc869f08317305119a99e0 /whisper/whisperv6
parenteb7f901289dce3f9fe3341da8c0b938ea839f79d (diff)
downloadgo-tangerine-5d30be412b0f9181cb007c8893ee583ee4319116.tar
go-tangerine-5d30be412b0f9181cb007c8893ee583ee4319116.tar.gz
go-tangerine-5d30be412b0f9181cb007c8893ee583ee4319116.tar.bz2
go-tangerine-5d30be412b0f9181cb007c8893ee583ee4319116.tar.lz
go-tangerine-5d30be412b0f9181cb007c8893ee583ee4319116.tar.xz
go-tangerine-5d30be412b0f9181cb007c8893ee583ee4319116.tar.zst
go-tangerine-5d30be412b0f9181cb007c8893ee583ee4319116.zip
all: switch out defunct set library to different one (#16873)
* keystore, ethash, eth, miner, rpc, whisperv6: tech debt with now defunct set. * whisperv5: swap out gopkg.in/fatih/set.v0 with supported set
Diffstat (limited to 'whisper/whisperv6')
-rw-r--r--whisper/whisperv6/api_test.go4
-rw-r--r--whisper/whisperv6/peer.go8
-rw-r--r--whisper/whisperv6/whisper.go10
3 files changed, 11 insertions, 11 deletions
diff --git a/whisper/whisperv6/api_test.go b/whisper/whisperv6/api_test.go
index 004a41c94..cdbc7fab5 100644
--- a/whisper/whisperv6/api_test.go
+++ b/whisper/whisperv6/api_test.go
@@ -22,8 +22,8 @@ import (
"testing"
"time"
+ mapset "github.com/deckarep/golang-set"
"github.com/ethereum/go-ethereum/common"
- set "gopkg.in/fatih/set.v0"
)
func TestMultipleTopicCopyInNewMessageFilter(t *testing.T) {
@@ -31,7 +31,7 @@ func TestMultipleTopicCopyInNewMessageFilter(t *testing.T) {
privateKeys: make(map[string]*ecdsa.PrivateKey),
symKeys: make(map[string][]byte),
envelopes: make(map[common.Hash]*Envelope),
- expirations: make(map[uint32]*set.SetNonTS),
+ expirations: make(map[uint32]mapset.Set),
peers: make(map[*Peer]struct{}),
messageQueue: make(chan *Envelope, messageQueueLimit),
p2pMsgQueue: make(chan *Envelope, messageQueueLimit),
diff --git a/whisper/whisperv6/peer.go b/whisper/whisperv6/peer.go
index 2bf1c905b..79cc21270 100644
--- a/whisper/whisperv6/peer.go
+++ b/whisper/whisperv6/peer.go
@@ -22,11 +22,11 @@ import (
"sync"
"time"
+ mapset "github.com/deckarep/golang-set"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/p2p"
"github.com/ethereum/go-ethereum/rlp"
- set "gopkg.in/fatih/set.v0"
)
// Peer represents a whisper protocol peer connection.
@@ -41,7 +41,7 @@ type Peer struct {
bloomFilter []byte
fullNode bool
- known *set.Set // Messages already known by the peer to avoid wasting bandwidth
+ known mapset.Set // Messages already known by the peer to avoid wasting bandwidth
quit chan struct{}
}
@@ -54,7 +54,7 @@ func newPeer(host *Whisper, remote *p2p.Peer, rw p2p.MsgReadWriter) *Peer {
ws: rw,
trusted: false,
powRequirement: 0.0,
- known: set.New(),
+ known: mapset.NewSet(),
quit: make(chan struct{}),
bloomFilter: MakeFullNodeBloom(),
fullNode: true,
@@ -165,7 +165,7 @@ func (peer *Peer) mark(envelope *Envelope) {
// marked checks if an envelope is already known to the remote peer.
func (peer *Peer) marked(envelope *Envelope) bool {
- return peer.known.Has(envelope.Hash())
+ return peer.known.Contains(envelope.Hash())
}
// expire iterates over all the known envelopes in the host and removes all
diff --git a/whisper/whisperv6/whisper.go b/whisper/whisperv6/whisper.go
index 3418c7bf7..76d485808 100644
--- a/whisper/whisperv6/whisper.go
+++ b/whisper/whisperv6/whisper.go
@@ -26,6 +26,7 @@ import (
"sync"
"time"
+ mapset "github.com/deckarep/golang-set"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/log"
@@ -35,7 +36,6 @@ import (
"github.com/syndtr/goleveldb/leveldb/errors"
"golang.org/x/crypto/pbkdf2"
"golang.org/x/sync/syncmap"
- set "gopkg.in/fatih/set.v0"
)
// Statistics holds several message-related counter for analytics
@@ -69,7 +69,7 @@ type Whisper struct {
poolMu sync.RWMutex // Mutex to sync the message and expiration pools
envelopes map[common.Hash]*Envelope // Pool of envelopes currently tracked by this node
- expirations map[uint32]*set.SetNonTS // Message expiration pool
+ expirations map[uint32]mapset.Set // Message expiration pool
peerMu sync.RWMutex // Mutex to sync the active peer set
peers map[*Peer]struct{} // Set of currently active peers
@@ -100,7 +100,7 @@ func New(cfg *Config) *Whisper {
privateKeys: make(map[string]*ecdsa.PrivateKey),
symKeys: make(map[string][]byte),
envelopes: make(map[common.Hash]*Envelope),
- expirations: make(map[uint32]*set.SetNonTS),
+ expirations: make(map[uint32]mapset.Set),
peers: make(map[*Peer]struct{}),
messageQueue: make(chan *Envelope, messageQueueLimit),
p2pMsgQueue: make(chan *Envelope, messageQueueLimit),
@@ -796,9 +796,9 @@ func (whisper *Whisper) add(envelope *Envelope, isP2P bool) (bool, error) {
if !alreadyCached {
whisper.envelopes[hash] = envelope
if whisper.expirations[envelope.Expiry] == nil {
- whisper.expirations[envelope.Expiry] = set.NewNonTS()
+ whisper.expirations[envelope.Expiry] = mapset.NewThreadUnsafeSet()
}
- if !whisper.expirations[envelope.Expiry].Has(hash) {
+ if !whisper.expirations[envelope.Expiry].Contains(hash) {
whisper.expirations[envelope.Expiry].Add(hash)
}
}