aboutsummaryrefslogtreecommitdiffstats
path: root/accounts/keystore/watch.go
diff options
context:
space:
mode:
Diffstat (limited to 'accounts/keystore/watch.go')
-rw-r--r--accounts/keystore/watch.go25
1 files changed, 8 insertions, 17 deletions
diff --git a/accounts/keystore/watch.go b/accounts/keystore/watch.go
index f4d647791..602300b10 100644
--- a/accounts/keystore/watch.go
+++ b/accounts/keystore/watch.go
@@ -70,7 +70,6 @@ func (w *watcher) loop() {
return
}
defer notify.Stop(w.ev)
-
logger.Trace("Started watching keystore folder")
defer logger.Trace("Stopped watching keystore folder")
@@ -82,9 +81,9 @@ func (w *watcher) loop() {
// When an event occurs, the reload call is delayed a bit so that
// multiple events arriving quickly only cause a single reload.
var (
- debounce = time.NewTimer(0)
- debounceDuration = 500 * time.Millisecond
- inCycle, hadEvent bool
+ debounce = time.NewTimer(0)
+ debounceDuration = 500 * time.Millisecond
+ rescanTriggered = false
)
defer debounce.Stop()
for {
@@ -92,22 +91,14 @@ func (w *watcher) loop() {
case <-w.quit:
return
case <-w.ev:
- if !inCycle {
+ // Trigger the scan (with delay), if not already triggered
+ if !rescanTriggered {
debounce.Reset(debounceDuration)
- inCycle = true
- } else {
- hadEvent = true
+ rescanTriggered = true
}
case <-debounce.C:
- w.ac.mu.Lock()
- w.ac.reload()
- w.ac.mu.Unlock()
- if hadEvent {
- debounce.Reset(debounceDuration)
- inCycle, hadEvent = true, false
- } else {
- inCycle, hadEvent = false, false
- }
+ w.ac.scanAccounts()
+ rescanTriggered = false
}
}
}