Skip to content

Commit 1c706d1

Browse files
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 <[email protected]>
1 parent 7ed17f1 commit 1c706d1

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

accounts/keystore/keystore.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,11 +196,14 @@ func (ks *KeyStore) Subscribe(sink chan<- accounts.WalletEvent) event.Subscripti
196196
// forces a manual refresh (only triggers for systems where the filesystem notifier
197197
// is not running).
198198
func (ks *KeyStore) updater() {
199+
ticker := time.NewTicker(walletRefreshCycle)
200+
defer ticker.Stop()
201+
199202
for {
200203
// Wait for an account update or a refresh timeout
201204
select {
202205
case <-ks.changes:
203-
case <-time.After(walletRefreshCycle):
206+
case <-ticker.C:
204207
}
205208
// Run the wallet refresher
206209
ks.refreshWallets()

0 commit comments

Comments
 (0)