Skip to content

Commit 7e5eac7

Browse files
committed
Upgrade golang-set
1 parent d67350b commit 7e5eac7

File tree

17 files changed

+95
-106
lines changed

17 files changed

+95
-106
lines changed

accounts/keystore/account_cache.go

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import (
2727
"sync"
2828
"time"
2929

30-
mapset "github.com/deckarep/golang-set"
30+
mapset "github.com/deckarep/golang-set/v2"
3131
"github.com/ethereum/go-ethereum/accounts"
3232
"github.com/ethereum/go-ethereum/common"
3333
"github.com/ethereum/go-ethereum/log"
@@ -79,7 +79,7 @@ func newAccountCache(keydir string) (*accountCache, chan struct{}) {
7979
keydir: keydir,
8080
byAddr: make(map[common.Address][]accounts.Account),
8181
notify: make(chan struct{}, 1),
82-
fileC: fileCache{all: mapset.NewThreadUnsafeSet()},
82+
fileC: fileCache{all: mapset.NewThreadUnsafeSet[string]()},
8383
}
8484
ac.watcher = newWatcher(ac)
8585
return ac, ac.notify
@@ -275,16 +275,15 @@ func (ac *accountCache) scanAccounts() error {
275275
// Process all the file diffs
276276
start := time.Now()
277277

278-
for _, p := range creates.ToSlice() {
279-
if a := readAccount(p.(string)); a != nil {
278+
for _, path := range creates.ToSlice() {
279+
if a := readAccount(path); a != nil {
280280
ac.add(*a)
281281
}
282282
}
283-
for _, p := range deletes.ToSlice() {
284-
ac.deleteByFile(p.(string))
283+
for _, path := range deletes.ToSlice() {
284+
ac.deleteByFile(path)
285285
}
286-
for _, p := range updates.ToSlice() {
287-
path := p.(string)
286+
for _, path := range updates.ToSlice() {
288287
ac.deleteByFile(path)
289288
if a := readAccount(path); a != nil {
290289
ac.add(*a)

accounts/keystore/file_cache.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,20 @@ import (
2323
"sync"
2424
"time"
2525

26-
mapset "github.com/deckarep/golang-set"
26+
mapset "github.com/deckarep/golang-set/v2"
2727
"github.com/ethereum/go-ethereum/log"
2828
)
2929

3030
// fileCache is a cache of files seen during scan of keystore.
3131
type fileCache struct {
32-
all mapset.Set // Set of all files from the keystore folder
33-
lastMod time.Time // Last time instance when a file was modified
32+
all mapset.Set[string] // Set of all files from the keystore folder
33+
lastMod time.Time // Last time instance when a file was modified
3434
mu sync.Mutex
3535
}
3636

3737
// scan performs a new scan on the given directory, compares against the already
3838
// cached filenames, and returns file sets: creates, deletes, updates.
39-
func (fc *fileCache) scan(keyDir string) (mapset.Set, mapset.Set, mapset.Set, error) {
39+
func (fc *fileCache) scan(keyDir string) (mapset.Set[string], mapset.Set[string], mapset.Set[string], error) {
4040
t0 := time.Now()
4141

4242
// List all the failes from the keystore folder
@@ -50,8 +50,8 @@ func (fc *fileCache) scan(keyDir string) (mapset.Set, mapset.Set, mapset.Set, er
5050
defer fc.mu.Unlock()
5151

5252
// Iterate all the files and gather their metadata
53-
all := mapset.NewThreadUnsafeSet()
54-
mods := mapset.NewThreadUnsafeSet()
53+
all := mapset.NewThreadUnsafeSet[string]()
54+
mods := mapset.NewThreadUnsafeSet[string]()
5555

5656
var newLastMod time.Time
5757
for _, fi := range files {

consensus/ethash/consensus.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import (
2222
"math/big"
2323
"time"
2424

25-
mapset "github.com/deckarep/golang-set"
25+
mapset "github.com/deckarep/golang-set/v2"
2626
"github.com/ethereum/go-ethereum/common"
2727
"github.com/ethereum/go-ethereum/common/math"
2828
"github.com/ethereum/go-ethereum/consensus"
@@ -153,7 +153,7 @@ func (ethash *Ethash) VerifyUncles(chain consensus.ChainReader, block *types.Blo
153153
return nil
154154
}
155155
// Gather the set of past uncles and ancestors
156-
uncles, ancestors := mapset.NewSet(), make(map[common.Hash]*types.Header)
156+
uncles, ancestors := mapset.NewSet[common.Hash](), make(map[common.Hash]*types.Header)
157157

158158
number, parent := block.NumberU64()-1, block.ParentHash()
159159
for i := 0; i < 7; i++ {

eth/fetcher/tx_fetcher.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import (
2323
"sort"
2424
"time"
2525

26-
mapset "github.com/deckarep/golang-set"
26+
mapset "github.com/deckarep/golang-set/v2"
2727
"github.com/ethereum/go-ethereum/common"
2828
"github.com/ethereum/go-ethereum/common/mclock"
2929
"github.com/ethereum/go-ethereum/core"
@@ -147,7 +147,7 @@ type TxFetcher struct {
147147
drop chan *txDrop
148148
quit chan struct{}
149149

150-
underpriced mapset.Set // Transactions discarded as too cheap (don't re-fetch)
150+
underpriced mapset.Set[common.Hash] // Transactions discarded as too cheap (don't re-fetch)
151151

152152
// Stage 1: Waiting lists for newly discovered transactions that might be
153153
// broadcast without needing explicit request/reply round trips.
@@ -201,7 +201,7 @@ func NewTxFetcherForTests(
201201
fetching: make(map[common.Hash]string),
202202
requests: make(map[string]*txRequest),
203203
alternates: make(map[common.Hash]map[string]struct{}),
204-
underpriced: mapset.NewSet(),
204+
underpriced: mapset.NewSet[common.Hash](),
205205
hasTx: hasTx,
206206
addTxs: addTxs,
207207
fetchTxs: fetchTxs,

eth/protocols/eth/peer.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121
"math/rand"
2222
"sync"
2323

24-
mapset "github.com/deckarep/golang-set"
24+
mapset "github.com/deckarep/golang-set/v2"
2525
"github.com/ethereum/go-ethereum/common"
2626
"github.com/ethereum/go-ethereum/core/types"
2727
"github.com/ethereum/go-ethereum/p2p"
@@ -75,14 +75,14 @@ type Peer struct {
7575
head common.Hash // Latest advertised head block hash
7676
td *big.Int // Latest advertised head block total difficulty
7777

78-
knownBlocks mapset.Set // Set of block hashes known to be known by this peer
79-
queuedBlocks chan *blockPropagation // Queue of blocks to broadcast to the peer
80-
queuedBlockAnns chan *types.Block // Queue of blocks to announce to the peer
78+
knownBlocks mapset.Set[common.Hash] // Set of block hashes known to be known by this peer
79+
queuedBlocks chan *blockPropagation // Queue of blocks to broadcast to the peer
80+
queuedBlockAnns chan *types.Block // Queue of blocks to announce to the peer
8181

82-
txpool TxPool // Transaction pool used by the broadcasters for liveness checks
83-
knownTxs mapset.Set // Set of transaction hashes known to be known by this peer
84-
txBroadcast chan []common.Hash // Channel used to queue transaction propagation requests
85-
txAnnounce chan []common.Hash // Channel used to queue transaction announcement requests
82+
txpool TxPool // Transaction pool used by the broadcasters for liveness checks
83+
knownTxs mapset.Set[common.Hash] // Set of transaction hashes known to be known by this peer
84+
txBroadcast chan []common.Hash // Channel used to queue transaction propagation requests
85+
txAnnounce chan []common.Hash // Channel used to queue transaction announcement requests
8686

8787
term chan struct{} // Termination channel to stop the broadcasters
8888
lock sync.RWMutex // Mutex protecting the internal fields
@@ -98,8 +98,8 @@ func NewPeer(version uint, p *p2p.Peer, rw p2p.MsgReadWriter, txpool TxPool) *Pe
9898
Peer: p,
9999
rw: rw,
100100
version: version,
101-
knownTxs: mapset.NewSet(),
102-
knownBlocks: mapset.NewSet(),
101+
knownTxs: mapset.NewSet[common.Hash](),
102+
knownBlocks: mapset.NewSet[common.Hash](),
103103
queuedBlocks: make(chan *blockPropagation, maxQueuedBlocks),
104104
queuedBlockAnns: make(chan *types.Block, maxQueuedBlockAnns),
105105
txBroadcast: make(chan []common.Hash),

eth/protocols/eth/qlight_deps.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package eth
22

33
import (
4-
mapset "github.com/deckarep/golang-set"
4+
mapset "github.com/deckarep/golang-set/v2"
55
"github.com/ethereum/go-ethereum/common"
66
"github.com/ethereum/go-ethereum/core"
77
"github.com/ethereum/go-ethereum/core/types"
@@ -47,8 +47,8 @@ func NewPeerNoBroadcast(version uint, p *p2p.Peer, rw p2p.MsgReadWriter, txpool
4747
Peer: p,
4848
rw: rw,
4949
version: version,
50-
knownTxs: mapset.NewSet(),
51-
knownBlocks: mapset.NewSet(),
50+
knownTxs: mapset.NewSet[common.Hash](),
51+
knownBlocks: mapset.NewSet[common.Hash](),
5252
queuedBlocks: make(chan *blockPropagation, maxQueuedBlocks),
5353
queuedBlockAnns: make(chan *types.Block, maxQueuedBlockAnns),
5454
txBroadcast: make(chan []common.Hash),

eth/protocols/qlight/peer.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package qlight
33
import (
44
"math/big"
55

6-
mapset "github.com/deckarep/golang-set"
6+
mapset "github.com/deckarep/golang-set/v2"
77
"github.com/ethereum/go-ethereum/common"
88
"github.com/ethereum/go-ethereum/core/types"
99
"github.com/ethereum/go-ethereum/eth/protocols/eth"
@@ -35,8 +35,8 @@ type Peer struct {
3535

3636
EthPeer *eth.Peer
3737

38-
knownBlocks mapset.Set // Set of block hashes known to be known by this peer
39-
queuedBlocks chan *blockPropagation // Queue of blocks to broadcast to the peer
38+
knownBlocks mapset.Set[common.Hash] // Set of block hashes known to be known by this peer
39+
queuedBlocks chan *blockPropagation // Queue of blocks to broadcast to the peer
4040

4141
term chan struct{} // Termination channel to stop the broadcasters
4242

@@ -59,7 +59,7 @@ func NewPeer(version uint, p *p2p.Peer, rw p2p.MsgReadWriter, ethPeer *eth.Peer)
5959
logger: log.New("peer", id[:8]),
6060
EthPeer: ethPeer,
6161
term: make(chan struct{}),
62-
knownBlocks: mapset.NewSet(),
62+
knownBlocks: mapset.NewSet[common.Hash](),
6363
queuedBlocks: make(chan *blockPropagation, maxQueuedBlocks),
6464
}
6565
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ require (
2222
github.com/consensys/gnark-crypto v0.14.0
2323
github.com/coreos/etcd v3.3.27+incompatible
2424
github.com/davecgh/go-spew v1.1.1
25-
github.com/deckarep/golang-set v1.8.0
25+
github.com/deckarep/golang-set/v2 v2.6.0
2626
github.com/docker/docker v27.2.1+incompatible
2727
github.com/dop251/goja v0.0.0-20200721192441-a695b0cdd498
2828
github.com/eapache/channels v1.1.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,8 @@ github.com/dave/jennifer v1.2.0/go.mod h1:fIb+770HOpJ2fmN9EPPKOqm1vMGhB+TwXKMZhr
158158
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
159159
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
160160
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
161-
github.com/deckarep/golang-set v1.8.0 h1:sk9/l/KqpunDwP7pSjUg0keiOOLEnOBHzykLrsPppp4=
162-
github.com/deckarep/golang-set v1.8.0/go.mod h1:5nI87KwE7wgsBU1F4GKAw2Qod7p5kyS383rP6+o6qqo=
161+
github.com/deckarep/golang-set/v2 v2.6.0 h1:XfcQbWM1LlMB8BsJ8N9vW5ehnnPVIw0je80NsVHagjM=
162+
github.com/deckarep/golang-set/v2 v2.6.0/go.mod h1:VAky9rY/yGXJOLEDv3OMci+7wtDpOF4IN+y82NBOac4=
163163
github.com/decred/dcrd/crypto/blake256 v1.0.1 h1:7PltbUIQB7u/FfZ39+DGa/ShuMyJ5ilcvdfma9wOH6Y=
164164
github.com/decred/dcrd/crypto/blake256 v1.0.1/go.mod h1:2OfgNZ5wDpcsFmHmCK5gZTPcCXqlm2ArzUIkw9czNJo=
165165
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 h1:rpfIENRNNilwHwZeG5+P150SMrnNEcHYvcCuK6dPZSg=

light/postprocess.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import (
2525
"math/big"
2626
"time"
2727

28-
mapset "github.com/deckarep/golang-set"
28+
mapset "github.com/deckarep/golang-set/v2"
2929
"github.com/ethereum/go-ethereum/common"
3030
"github.com/ethereum/go-ethereum/common/bitutil"
3131
"github.com/ethereum/go-ethereum/core"
@@ -134,7 +134,7 @@ type ChtIndexerBackend struct {
134134
diskdb, trieTable ethdb.Database
135135
odr OdrBackend
136136
triedb *trie.Database
137-
trieset mapset.Set
137+
trieset mapset.Set[common.Hash]
138138
section, sectionSize uint64
139139
lastHash common.Hash
140140
trie *trie.Trie
@@ -148,7 +148,7 @@ func NewChtIndexer(db ethdb.Database, odr OdrBackend, size, confirms uint64, dis
148148
odr: odr,
149149
trieTable: trieTable,
150150
triedb: trie.NewDatabaseWithConfig(trieTable, &trie.Config{Cache: 1}), // Use a tiny cache only to keep memory down
151-
trieset: mapset.NewSet(),
151+
trieset: mapset.NewSet[common.Hash](),
152152
sectionSize: size,
153153
disablePruning: disablePruning,
154154
}
@@ -323,7 +323,7 @@ type BloomTrieIndexerBackend struct {
323323
disablePruning bool
324324
diskdb, trieTable ethdb.Database
325325
triedb *trie.Database
326-
trieset mapset.Set
326+
trieset mapset.Set[common.Hash]
327327
odr OdrBackend
328328
section uint64
329329
parentSize uint64
@@ -341,7 +341,7 @@ func NewBloomTrieIndexer(db ethdb.Database, odr OdrBackend, parentSize, size uin
341341
odr: odr,
342342
trieTable: trieTable,
343343
triedb: trie.NewDatabaseWithConfig(trieTable, &trie.Config{Cache: 1}), // Use a tiny cache only to keep memory down
344-
trieset: mapset.NewSet(),
344+
trieset: mapset.NewSet[common.Hash](),
345345
parentSize: parentSize,
346346
size: size,
347347
disablePruning: disablePruning,

0 commit comments

Comments
 (0)