mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 02:12:23 +00:00
whisperv5: swap out gopkg.in/fatih/set.v0 with supported set
This commit is contained in:
parent
d317e9bf86
commit
70a114c46c
3 changed files with 9 additions and 15 deletions
6
vendor/vendor.json
vendored
6
vendor/vendor.json
vendored
|
|
@ -741,12 +741,6 @@
|
|||
"revision": "20d25e2804050c1cd24a7eea1e7a6447dd0e74ec",
|
||||
"revisionTime": "2016-12-08T18:13:25Z"
|
||||
},
|
||||
{
|
||||
"checksumSHA1": "NGg7/qIJVUfXi7xnEyyDLocdi6Y=",
|
||||
"path": "gopkg.in/fatih/set.v0",
|
||||
"revision": "27c40922c40b43fe04554d8223a402af3ea333f3",
|
||||
"revisionTime": "2014-12-10T08:48:24Z"
|
||||
},
|
||||
{
|
||||
"checksumSHA1": "DQXNV0EivoHm4q+bkdahYXrjjfE=",
|
||||
"path": "gopkg.in/karalabe/cookiejar.v2/collections/prque",
|
||||
|
|
|
|||
|
|
@ -20,11 +20,11 @@ import (
|
|||
"fmt"
|
||||
"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.
|
||||
|
|
@ -34,7 +34,7 @@ type Peer struct {
|
|||
ws p2p.MsgReadWriter
|
||||
trusted 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{}
|
||||
}
|
||||
|
|
@ -46,7 +46,7 @@ func newPeer(host *Whisper, remote *p2p.Peer, rw p2p.MsgReadWriter) *Peer {
|
|||
peer: remote,
|
||||
ws: rw,
|
||||
trusted: false,
|
||||
known: set.New(),
|
||||
known: mapset.NewSet(),
|
||||
quit: make(chan struct{}),
|
||||
}
|
||||
}
|
||||
|
|
@ -127,7 +127,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
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
@ -34,7 +35,6 @@ import (
|
|||
"github.com/syndtr/goleveldb/leveldb/errors"
|
||||
"golang.org/x/crypto/pbkdf2"
|
||||
"golang.org/x/sync/syncmap"
|
||||
set "gopkg.in/fatih/set.v0"
|
||||
)
|
||||
|
||||
type Statistics struct {
|
||||
|
|
@ -63,7 +63,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
|
||||
|
|
@ -90,7 +90,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),
|
||||
|
|
@ -608,9 +608,9 @@ func (w *Whisper) add(envelope *Envelope) (bool, error) {
|
|||
if !alreadyCached {
|
||||
w.envelopes[hash] = envelope
|
||||
if w.expirations[envelope.Expiry] == nil {
|
||||
w.expirations[envelope.Expiry] = set.NewNonTS()
|
||||
w.expirations[envelope.Expiry] = mapset.NewThreadUnsafeSet()
|
||||
}
|
||||
if !w.expirations[envelope.Expiry].Has(hash) {
|
||||
if !w.expirations[envelope.Expiry].Contains(hash) {
|
||||
w.expirations[envelope.Expiry].Add(hash)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue