mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-06 23:18:37 +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
|
// 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() {
|
||||||
|
ticker := time.NewTicker(walletRefreshCycle)
|
||||||
|
defer ticker.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:
|
||||||
case <-time.After(walletRefreshCycle):
|
case <-ticker.C:
|
||||||
}
|
}
|
||||||
// Run the wallet refresher
|
// Run the wallet refresher
|
||||||
ks.refreshWallets()
|
ks.refreshWallets()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue