diff --git a/accounts/keystore/account_cache.go b/accounts/keystore/account_cache.go index b5cc75c48d..f7cf688e62 100644 --- a/accounts/keystore/account_cache.go +++ b/accounts/keystore/account_cache.go @@ -220,7 +220,6 @@ func (ac *accountCache) maybeReload() { ac.watcher.start() ac.throttle.Reset(minReloadInterval) ac.mu.Unlock() - ac.watcher.startupWG.Wait() ac.scanAccounts() } diff --git a/accounts/keystore/account_cache_test.go b/accounts/keystore/account_cache_test.go index 1a9f9a4714..6bc14f5bb6 100644 --- a/accounts/keystore/account_cache_test.go +++ b/accounts/keystore/account_cache_test.go @@ -326,6 +326,11 @@ func TestUpdatedKeyfileContents(t *testing.T) { // Create a temporary keystore to test with dir := filepath.Join(os.TempDir(), fmt.Sprintf("eth-keystore-updatedkeyfilecontents-test-%d-%d", os.Getpid(), rand.Int())) + + // Create the directory + os.MkdirAll(dir, 0700) + defer os.RemoveAll(dir) + ks := NewKeyStore(dir, LightScryptN, LightScryptP) list := ks.Accounts() @@ -335,9 +340,7 @@ func TestUpdatedKeyfileContents(t *testing.T) { if !waitWatcherStart(ks) { t.Fatal("keystore watcher didn't start in time") } - // Create the directory and copy a key file into it. - os.MkdirAll(dir, 0700) - defer os.RemoveAll(dir) + // Copy a key file into it file := filepath.Join(dir, "aaa") // Place one of our testfiles in there diff --git a/accounts/keystore/watch.go b/accounts/keystore/watch.go index cededf1941..1bef321cd1 100644 --- a/accounts/keystore/watch.go +++ b/accounts/keystore/watch.go @@ -21,7 +21,6 @@ package keystore import ( "os" - "sync" "time" "github.com/ethereum/go-ethereum/log" @@ -29,19 +28,17 @@ import ( ) type watcher struct { - ac *accountCache - running bool // set to true when runloop begins - runEnded bool // set to true when runloop ends - starting bool // set to true prior to runloop starting - quit chan struct{} - startupWG sync.WaitGroup // wait for watcher loop to start + ac *accountCache + running bool // set to true when runloop begins + runEnded bool // set to true when runloop ends + starting bool // set to true prior to runloop starting + quit chan struct{} } func newWatcher(ac *accountCache) *watcher { return &watcher{ - ac: ac, - quit: make(chan struct{}), - startupWG: sync.WaitGroup{}, + ac: ac, + quit: make(chan struct{}), } } @@ -55,7 +52,6 @@ func (w *watcher) start() { if w.starting || w.running { return } - w.startupWG.Add(1) w.starting = true go w.loop() } @@ -85,7 +81,6 @@ func (w *watcher) loop() { if !os.IsNotExist(err) { logger.Warn("Failed to watch keystore folder", "err", err) } - w.startupWG.Done() return } @@ -109,7 +104,6 @@ func (w *watcher) loop() { <-debounce.C } defer debounce.Stop() - w.startupWG.Done() for { select { case <-w.quit: