aboutsummaryrefslogtreecommitdiffstats
path: root/accounts
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 /accounts
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 'accounts')
-rw-r--r--accounts/keystore/account_cache.go12
-rw-r--r--accounts/keystore/file_cache.go18
2 files changed, 15 insertions, 15 deletions
diff --git a/accounts/keystore/account_cache.go b/accounts/keystore/account_cache.go
index 71f698ece..da3a46eb8 100644
--- a/accounts/keystore/account_cache.go
+++ b/accounts/keystore/account_cache.go
@@ -27,10 +27,10 @@ import (
"sync"
"time"
+ mapset "github.com/deckarep/golang-set"
"github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/log"
- "gopkg.in/fatih/set.v0"
)
// Minimum amount of time between cache reloads. This limit applies if the platform does
@@ -79,7 +79,7 @@ func newAccountCache(keydir string) (*accountCache, chan struct{}) {
keydir: keydir,
byAddr: make(map[common.Address][]accounts.Account),
notify: make(chan struct{}, 1),
- fileC: fileCache{all: set.NewNonTS()},
+ fileC: fileCache{all: mapset.NewThreadUnsafeSet()},
}
ac.watcher = newWatcher(ac)
return ac, ac.notify
@@ -237,7 +237,7 @@ func (ac *accountCache) scanAccounts() error {
log.Debug("Failed to reload keystore contents", "err", err)
return err
}
- if creates.Size() == 0 && deletes.Size() == 0 && updates.Size() == 0 {
+ if creates.Cardinality() == 0 && deletes.Cardinality() == 0 && updates.Cardinality() == 0 {
return nil
}
// Create a helper method to scan the contents of the key files
@@ -272,15 +272,15 @@ func (ac *accountCache) scanAccounts() error {
// Process all the file diffs
start := time.Now()
- for _, p := range creates.List() {
+ for _, p := range creates.ToSlice() {
if a := readAccount(p.(string)); a != nil {
ac.add(*a)
}
}
- for _, p := range deletes.List() {
+ for _, p := range deletes.ToSlice() {
ac.deleteByFile(p.(string))
}
- for _, p := range updates.List() {
+ for _, p := range updates.ToSlice() {
path := p.(string)
ac.deleteByFile(path)
if a := readAccount(path); a != nil {
diff --git a/accounts/keystore/file_cache.go b/accounts/keystore/file_cache.go
index c91b7b7b6..26da34dcf 100644
--- a/accounts/keystore/file_cache.go
+++ b/accounts/keystore/file_cache.go
@@ -24,20 +24,20 @@ import (
"sync"
"time"
+ mapset "github.com/deckarep/golang-set"
"github.com/ethereum/go-ethereum/log"
- set "gopkg.in/fatih/set.v0"
)
// fileCache is a cache of files seen during scan of keystore.
type fileCache struct {
- all *set.SetNonTS // Set of all files from the keystore folder
- lastMod time.Time // Last time instance when a file was modified
+ all mapset.Set // Set of all files from the keystore folder
+ lastMod time.Time // Last time instance when a file was modified
mu sync.RWMutex
}
// scan performs a new scan on the given directory, compares against the already
// cached filenames, and returns file sets: creates, deletes, updates.
-func (fc *fileCache) scan(keyDir string) (set.Interface, set.Interface, set.Interface, error) {
+func (fc *fileCache) scan(keyDir string) (mapset.Set, mapset.Set, mapset.Set, error) {
t0 := time.Now()
// List all the failes from the keystore folder
@@ -51,8 +51,8 @@ func (fc *fileCache) scan(keyDir string) (set.Interface, set.Interface, set.Inte
defer fc.mu.Unlock()
// Iterate all the files and gather their metadata
- all := set.NewNonTS()
- mods := set.NewNonTS()
+ all := mapset.NewThreadUnsafeSet()
+ mods := mapset.NewThreadUnsafeSet()
var newLastMod time.Time
for _, fi := range files {
@@ -76,9 +76,9 @@ func (fc *fileCache) scan(keyDir string) (set.Interface, set.Interface, set.Inte
t2 := time.Now()
// Update the tracked files and return the three sets
- deletes := set.Difference(fc.all, all) // Deletes = previous - current
- creates := set.Difference(all, fc.all) // Creates = current - previous
- updates := set.Difference(mods, creates) // Updates = modified - creates
+ deletes := fc.all.Difference(all) // Deletes = previous - current
+ creates := all.Difference(fc.all) // Creates = current - previous
+ updates := mods.Difference(creates) // Updates = modified - creates
fc.all, fc.lastMod = all, newLastMod
t3 := time.Now()