aboutsummaryrefslogtreecommitdiffstats
path: root/eth/peer.go
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 /eth/peer.go
parenteb7f901289dce3f9fe3341da8c0b938ea839f79d (diff)
downloaddexon-5d30be412b0f9181cb007c8893ee583ee4319116.tar
dexon-5d30be412b0f9181cb007c8893ee583ee4319116.tar.gz
dexon-5d30be412b0f9181cb007c8893ee583ee4319116.tar.bz2
dexon-5d30be412b0f9181cb007c8893ee583ee4319116.tar.lz
dexon-5d30be412b0f9181cb007c8893ee583ee4319116.tar.xz
dexon-5d30be412b0f9181cb007c8893ee583ee4319116.tar.zst
dexon-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 'eth/peer.go')
-rw-r--r--eth/peer.go18
1 files changed, 9 insertions, 9 deletions
diff --git a/eth/peer.go b/eth/peer.go
index 953aca17b..b5f450855 100644
--- a/eth/peer.go
+++ b/eth/peer.go
@@ -23,11 +23,11 @@ import (
"sync"
"time"
+ mapset "github.com/deckarep/golang-set"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/p2p"
"github.com/ethereum/go-ethereum/rlp"
- "gopkg.in/fatih/set.v0"
)
var (
@@ -85,8 +85,8 @@ type peer struct {
td *big.Int
lock sync.RWMutex
- knownTxs *set.Set // Set of transaction hashes known to be known by this peer
- knownBlocks *set.Set // Set of block hashes known to be known by this peer
+ knownTxs mapset.Set // Set of transaction hashes known to be known by this peer
+ knownBlocks mapset.Set // Set of block hashes known to be known by this peer
queuedTxs chan []*types.Transaction // Queue of transactions to broadcast to the peer
queuedProps chan *propEvent // Queue of blocks to broadcast to the peer
queuedAnns chan *types.Block // Queue of blocks to announce to the peer
@@ -99,8 +99,8 @@ func newPeer(version int, p *p2p.Peer, rw p2p.MsgReadWriter) *peer {
rw: rw,
version: version,
id: fmt.Sprintf("%x", p.ID().Bytes()[:8]),
- knownTxs: set.New(),
- knownBlocks: set.New(),
+ knownTxs: mapset.NewSet(),
+ knownBlocks: mapset.NewSet(),
queuedTxs: make(chan []*types.Transaction, maxQueuedTxs),
queuedProps: make(chan *propEvent, maxQueuedProps),
queuedAnns: make(chan *types.Block, maxQueuedAnns),
@@ -177,7 +177,7 @@ func (p *peer) SetHead(hash common.Hash, td *big.Int) {
// never be propagated to this particular peer.
func (p *peer) MarkBlock(hash common.Hash) {
// If we reached the memory allowance, drop a previously known block hash
- for p.knownBlocks.Size() >= maxKnownBlocks {
+ for p.knownBlocks.Cardinality() >= maxKnownBlocks {
p.knownBlocks.Pop()
}
p.knownBlocks.Add(hash)
@@ -187,7 +187,7 @@ func (p *peer) MarkBlock(hash common.Hash) {
// will never be propagated to this particular peer.
func (p *peer) MarkTransaction(hash common.Hash) {
// If we reached the memory allowance, drop a previously known transaction hash
- for p.knownTxs.Size() >= maxKnownTxs {
+ for p.knownTxs.Cardinality() >= maxKnownTxs {
p.knownTxs.Pop()
}
p.knownTxs.Add(hash)
@@ -470,7 +470,7 @@ func (ps *peerSet) PeersWithoutBlock(hash common.Hash) []*peer {
list := make([]*peer, 0, len(ps.peers))
for _, p := range ps.peers {
- if !p.knownBlocks.Has(hash) {
+ if !p.knownBlocks.Contains(hash) {
list = append(list, p)
}
}
@@ -485,7 +485,7 @@ func (ps *peerSet) PeersWithoutTx(hash common.Hash) []*peer {
list := make([]*peer, 0, len(ps.peers))
for _, p := range ps.peers {
- if !p.knownTxs.Has(hash) {
+ if !p.knownTxs.Contains(hash) {
list = append(list, p)
}
}