mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-02-26 07:37:20 +00:00
accounts/keystore: use ticker to avoid timer allocations (#32732)
Replace time.After with a long‑lived time.Ticker in KeyStore.updater, preventing per‑iteration timer allocations and potential timer buildup. Co-authored-by: lightclient <lightclient@protonmail.com>
This commit is contained in:
parent
7ed17f1933
commit
1c706d1571
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