aboutsummaryrefslogtreecommitdiffstats
path: root/eth/peer.go
diff options
context:
space:
mode:
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)
}
}