mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-17 01:13:45 +00:00
account/keystore : make fs watcher use not block account ops during fs scan
This commit is contained in:
parent
a92d8a2654
commit
ad11cf5100
2 changed files with 8 additions and 1 deletions
|
|
@ -209,6 +209,12 @@ func (ac *accountCache) close() {
|
||||||
// Callers must hold ac.mu.
|
// Callers must hold ac.mu.
|
||||||
func (ac *accountCache) reload() {
|
func (ac *accountCache) reload() {
|
||||||
accounts, err := ac.scan()
|
accounts, err := ac.scan()
|
||||||
|
ac.handleScanResult(accounts, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// handleScanResult uses the result of a fs scan to update the account lists
|
||||||
|
// This can be used to perform un-mutexed fs scans
|
||||||
|
func (ac *accountCache) handleScanResult(accounts []accounts.Account, err error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Debug("Failed to reload keystore contents", "err", err)
|
log.Debug("Failed to reload keystore contents", "err", err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -99,8 +99,9 @@ func (w *watcher) loop() {
|
||||||
hadEvent = true
|
hadEvent = true
|
||||||
}
|
}
|
||||||
case <-debounce.C:
|
case <-debounce.C:
|
||||||
|
accounts, err := w.ac.scan()
|
||||||
w.ac.mu.Lock()
|
w.ac.mu.Lock()
|
||||||
w.ac.reload()
|
w.ac.handleScanResult(accounts, err)
|
||||||
w.ac.mu.Unlock()
|
w.ac.mu.Unlock()
|
||||||
if hadEvent {
|
if hadEvent {
|
||||||
debounce.Reset(debounceDuration)
|
debounce.Reset(debounceDuration)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue