mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 18:32:23 +00:00
accounts: fix TestUpdateKeyfileContents
This commit is contained in:
parent
7224576fba
commit
6a6bdab463
2 changed files with 8 additions and 0 deletions
|
|
@ -220,6 +220,7 @@ func (ac *accountCache) maybeReload() {
|
||||||
ac.watcher.start()
|
ac.watcher.start()
|
||||||
ac.throttle.Reset(minReloadInterval)
|
ac.throttle.Reset(minReloadInterval)
|
||||||
ac.mu.Unlock()
|
ac.mu.Unlock()
|
||||||
|
ac.watcher.wg.Wait()
|
||||||
ac.scanAccounts()
|
ac.scanAccounts()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ package keystore
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/log"
|
"github.com/ethereum/go-ethereum/log"
|
||||||
|
|
@ -33,12 +34,14 @@ type watcher struct {
|
||||||
runEnded bool // set to true when runloop ends
|
runEnded bool // set to true when runloop ends
|
||||||
starting bool // set to true prior to runloop starting
|
starting bool // set to true prior to runloop starting
|
||||||
quit chan struct{}
|
quit chan struct{}
|
||||||
|
wg sync.WaitGroup // wait for watcher loop to start
|
||||||
}
|
}
|
||||||
|
|
||||||
func newWatcher(ac *accountCache) *watcher {
|
func newWatcher(ac *accountCache) *watcher {
|
||||||
return &watcher{
|
return &watcher{
|
||||||
ac: ac,
|
ac: ac,
|
||||||
quit: make(chan struct{}),
|
quit: make(chan struct{}),
|
||||||
|
wg: sync.WaitGroup{},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -52,6 +55,7 @@ func (w *watcher) start() {
|
||||||
if w.starting || w.running {
|
if w.starting || w.running {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
w.wg.Add(1)
|
||||||
w.starting = true
|
w.starting = true
|
||||||
go w.loop()
|
go w.loop()
|
||||||
}
|
}
|
||||||
|
|
@ -77,10 +81,12 @@ func (w *watcher) loop() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer watcher.Close()
|
defer watcher.Close()
|
||||||
|
|
||||||
if err := watcher.Add(w.ac.keydir); err != nil {
|
if err := watcher.Add(w.ac.keydir); err != nil {
|
||||||
if !os.IsNotExist(err) {
|
if !os.IsNotExist(err) {
|
||||||
logger.Warn("Failed to watch keystore folder", "err", err)
|
logger.Warn("Failed to watch keystore folder", "err", err)
|
||||||
}
|
}
|
||||||
|
w.wg.Done()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -104,6 +110,7 @@ func (w *watcher) loop() {
|
||||||
<-debounce.C
|
<-debounce.C
|
||||||
}
|
}
|
||||||
defer debounce.Stop()
|
defer debounce.Stop()
|
||||||
|
w.wg.Done()
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-w.quit:
|
case <-w.quit:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue