mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-23 05:06:43 +00:00
accounts/keystore: use ticker to avoid timer allocs
Co-authored-by: viktorking7 <140458814+viktorking7@users.noreply.github.com> Co-authored-by: lightclient <lightclient@protonmail.com>
This commit is contained in:
parent
48c74f4593
commit
9ba425bdd1
1 changed files with 4 additions and 1 deletions
|
|
@ -196,11 +196,14 @@ func (ks *KeyStore) Subscribe(sink chan<- accounts.WalletEvent) event.Subscripti
|
|||
// forces a manual refresh (only triggers for systems where the filesystem notifier
|
||||
// is not running).
|
||||
func (ks *KeyStore) updater() {
|
||||
ticker := time.NewTicker(walletRefreshCycle)
|
||||
defer ticker.Stop()
|
||||
|
||||
for {
|
||||
// Wait for an account update or a refresh timeout
|
||||
select {
|
||||
case <-ks.changes:
|
||||
case <-time.After(walletRefreshCycle):
|
||||
case <-ticker.C:
|
||||
}
|
||||
// Run the wallet refresher
|
||||
ks.refreshWallets()
|
||||
|
|
|
|||
Loading…
Reference in a new issue