mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-15 17:30:44 +00:00
This commit is contained in:
parent
f9f47d2836
commit
7c5d2a45da
1 changed files with 3 additions and 12 deletions
|
|
@ -196,23 +196,17 @@ func (ks *KeyStore) Subscribe(sink chan<- accounts.WalletEvent) event.Subscripti
|
||||||
// forces a manual refresh (only triggers for systems where the filesystem notifier
|
// forces a manual refresh (only triggers for systems where the filesystem notifier
|
||||||
// is not running).
|
// is not running).
|
||||||
func (ks *KeyStore) updater() {
|
func (ks *KeyStore) updater() {
|
||||||
// Create a timer for the wallet refresh cycle
|
ticker := time.NewTicker(walletRefreshCycle)
|
||||||
timer := time.NewTimer(walletRefreshCycle)
|
defer ticker.Stop()
|
||||||
defer timer.Stop()
|
|
||||||
|
|
||||||
for {
|
for {
|
||||||
// Wait for an account update or a refresh timeout
|
// Wait for an account update or a refresh timeout
|
||||||
select {
|
select {
|
||||||
case <-ks.changes:
|
case <-ks.changes:
|
||||||
// Stop the timer if we receive an account update before the timer fires
|
case <-ticker.C:
|
||||||
if !timer.Stop() {
|
|
||||||
<-timer.C
|
|
||||||
}
|
|
||||||
case <-timer.C:
|
|
||||||
}
|
}
|
||||||
// Run the wallet refresher
|
// Run the wallet refresher
|
||||||
ks.refreshWallets()
|
ks.refreshWallets()
|
||||||
|
|
||||||
// If all our subscribers left, stop the updater
|
// If all our subscribers left, stop the updater
|
||||||
ks.mu.Lock()
|
ks.mu.Lock()
|
||||||
if ks.updateScope.Count() == 0 {
|
if ks.updateScope.Count() == 0 {
|
||||||
|
|
@ -221,9 +215,6 @@ func (ks *KeyStore) updater() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
ks.mu.Unlock()
|
ks.mu.Unlock()
|
||||||
|
|
||||||
// Reset the timer for the next cycle
|
|
||||||
timer.Reset(walletRefreshCycle)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue