mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-16 17:03:46 +00:00
account/keystore : make fs watcher use not block account ops during fs scan
This commit is contained in:
parent
dc92779c0a
commit
9929bcc40d
2 changed files with 8 additions and 1 deletions
|
|
@ -209,6 +209,12 @@ func (ac *accountCache) close() {
|
|||
// Callers must hold ac.mu.
|
||||
func (ac *accountCache) reload() {
|
||||
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 {
|
||||
log.Debug("Failed to reload keystore contents", "err", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -99,8 +99,9 @@ func (w *watcher) loop() {
|
|||
hadEvent = true
|
||||
}
|
||||
case <-debounce.C:
|
||||
accounts, err := w.ac.scan()
|
||||
w.ac.mu.Lock()
|
||||
w.ac.reload()
|
||||
w.ac.handleScanResult(accounts, err)
|
||||
w.ac.mu.Unlock()
|
||||
if hadEvent {
|
||||
debounce.Reset(debounceDuration)
|
||||
|
|
|
|||
Loading…
Reference in a new issue