mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-17 09:23:48 +00:00
accounts/keystore: fix more style nits
This commit is contained in:
parent
46aa352f9b
commit
d6fa6eabcf
1 changed files with 8 additions and 12 deletions
|
|
@ -77,8 +77,8 @@ type accountCache struct {
|
||||||
|
|
||||||
// fileCache is a cache of files seen during scan of keystore
|
// fileCache is a cache of files seen during scan of keystore
|
||||||
type fileCache struct {
|
type fileCache struct {
|
||||||
all *set.SetNonTS //List of all files
|
all *set.SetNonTS // list of all files
|
||||||
mtime *time.Time //Latest mtime seen
|
mtime time.Time // latest mtime seen
|
||||||
mu sync.RWMutex
|
mu sync.RWMutex
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -87,10 +87,7 @@ func newAccountCache(keydir string) (*accountCache, chan struct{}) {
|
||||||
keydir: keydir,
|
keydir: keydir,
|
||||||
byAddr: make(map[common.Address][]accounts.Account),
|
byAddr: make(map[common.Address][]accounts.Account),
|
||||||
notify: make(chan struct{}, 1),
|
notify: make(chan struct{}, 1),
|
||||||
fileC: fileCache{
|
fileC: fileCache{all: set.NewNonTS()},
|
||||||
all: set.NewNonTS(),
|
|
||||||
mtime: new(time.Time),
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
ac.watcher = newWatcher(ac)
|
ac.watcher = newWatcher(ac)
|
||||||
return ac, ac.notify
|
return ac, ac.notify
|
||||||
|
|
@ -248,12 +245,12 @@ func (fc *fileCache) scanFiles(keyDir string) (set.Interface, set.Interface, set
|
||||||
return nil, nil, nil, err
|
return nil, nil, nil, err
|
||||||
}
|
}
|
||||||
fc.mu.RLock()
|
fc.mu.RLock()
|
||||||
previous_mtime := fc.mtime
|
prevMtime := fc.mtime
|
||||||
fc.mu.RUnlock()
|
fc.mu.RUnlock()
|
||||||
|
|
||||||
filesNow := set.NewNonTS()
|
filesNow := set.NewNonTS()
|
||||||
moddedFiles := set.NewNonTS()
|
moddedFiles := set.NewNonTS()
|
||||||
newMtime := new(time.Time)
|
var newMtime time.Time
|
||||||
for _, fi := range files {
|
for _, fi := range files {
|
||||||
modTime := fi.ModTime()
|
modTime := fi.ModTime()
|
||||||
path := filepath.Join(keyDir, fi.Name())
|
path := filepath.Join(keyDir, fi.Name())
|
||||||
|
|
@ -262,11 +259,11 @@ func (fc *fileCache) scanFiles(keyDir string) (set.Interface, set.Interface, set
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
filesNow.Add(path)
|
filesNow.Add(path)
|
||||||
if modTime.After(*previous_mtime) {
|
if modTime.After(prevMtime) {
|
||||||
moddedFiles.Add(path)
|
moddedFiles.Add(path)
|
||||||
}
|
}
|
||||||
if modTime.After(*newMtime) {
|
if modTime.After(newMtime) {
|
||||||
newMtime = &modTime
|
newMtime = modTime
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
t2 := time.Now()
|
t2 := time.Now()
|
||||||
|
|
@ -289,7 +286,6 @@ func (fc *fileCache) scanFiles(keyDir string) (set.Interface, set.Interface, set
|
||||||
// scanAccounts checks if any changes have occurred on the filesystem, and
|
// scanAccounts checks if any changes have occurred on the filesystem, and
|
||||||
// updates the account cache accordingly
|
// updates the account cache accordingly
|
||||||
func (ac *accountCache) scanAccounts() error {
|
func (ac *accountCache) scanAccounts() error {
|
||||||
|
|
||||||
newFiles, missingFiles, modified, err := ac.fileC.scanFiles(ac.keydir)
|
newFiles, missingFiles, modified, err := ac.fileC.scanFiles(ac.keydir)
|
||||||
t1 := time.Now()
|
t1 := time.Now()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue