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:
viktorking7 2025-09-25 03:47:55 +02:00 committed by GitHub
parent 7ed17f1933
commit 1c706d1571
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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()