@@ -23,11 +23,11 @@ import (
2323 "sync"
2424 "time"
2525
26+ mapset "github.com/deckarep/golang-set"
2627 "github.com/ethereum/go-ethereum/common"
2728 "github.com/ethereum/go-ethereum/core/types"
2829 "github.com/ethereum/go-ethereum/p2p"
2930 "github.com/ethereum/go-ethereum/rlp"
30- "gopkg.in/fatih/set.v0"
3131)
3232
3333var (
@@ -85,8 +85,8 @@ type peer struct {
8585 td * big.Int
8686 lock sync.RWMutex
8787
88- knownTxs * set .Set // Set of transaction hashes known to be known by this peer
89- knownBlocks * set .Set // Set of block hashes known to be known by this peer
88+ knownTxs mapset .Set // Set of transaction hashes known to be known by this peer
89+ knownBlocks mapset .Set // Set of block hashes known to be known by this peer
9090 queuedTxs chan []* types.Transaction // Queue of transactions to broadcast to the peer
9191 queuedProps chan * propEvent // Queue of blocks to broadcast to the peer
9292 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 {
9999 rw : rw ,
100100 version : version ,
101101 id : fmt .Sprintf ("%x" , p .ID ().Bytes ()[:8 ]),
102- knownTxs : set . New (),
103- knownBlocks : set . New (),
102+ knownTxs : mapset . NewSet (),
103+ knownBlocks : mapset . NewSet (),
104104 queuedTxs : make (chan []* types.Transaction , maxQueuedTxs ),
105105 queuedProps : make (chan * propEvent , maxQueuedProps ),
106106 queuedAnns : make (chan * types.Block , maxQueuedAnns ),
@@ -177,7 +177,7 @@ func (p *peer) SetHead(hash common.Hash, td *big.Int) {
177177// never be propagated to this particular peer.
178178func (p * peer ) MarkBlock (hash common.Hash ) {
179179 // If we reached the memory allowance, drop a previously known block hash
180- for p .knownBlocks .Size () >= maxKnownBlocks {
180+ for p .knownBlocks .Cardinality () >= maxKnownBlocks {
181181 p .knownBlocks .Pop ()
182182 }
183183 p .knownBlocks .Add (hash )
@@ -187,7 +187,7 @@ func (p *peer) MarkBlock(hash common.Hash) {
187187// will never be propagated to this particular peer.
188188func (p * peer ) MarkTransaction (hash common.Hash ) {
189189 // If we reached the memory allowance, drop a previously known transaction hash
190- for p .knownTxs .Size () >= maxKnownTxs {
190+ for p .knownTxs .Cardinality () >= maxKnownTxs {
191191 p .knownTxs .Pop ()
192192 }
193193 p .knownTxs .Add (hash )
@@ -470,7 +470,7 @@ func (ps *peerSet) PeersWithoutBlock(hash common.Hash) []*peer {
470470
471471 list := make ([]* peer , 0 , len (ps .peers ))
472472 for _ , p := range ps .peers {
473- if ! p .knownBlocks .Has (hash ) {
473+ if ! p .knownBlocks .Contains (hash ) {
474474 list = append (list , p )
475475 }
476476 }
@@ -485,7 +485,7 @@ func (ps *peerSet) PeersWithoutTx(hash common.Hash) []*peer {
485485
486486 list := make ([]* peer , 0 , len (ps .peers ))
487487 for _ , p := range ps .peers {
488- if ! p .knownTxs .Has (hash ) {
488+ if ! p .knownTxs .Contains (hash ) {
489489 list = append (list , p )
490490 }
491491 }
0 commit comments