Skip to content

Commit bec320e

Browse files
viktorking7lightclient
authored andcommitted
accounts/keystore: use ticker to avoid timer allocations (ethereum#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 0d246b7 commit bec320e

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)