From 1c706d1571d6e61754631ae6f0ae73d54ed4d44a Mon Sep 17 00:00:00 2001 From: viktorking7 <140458814+viktorking7@users.noreply.github.com> Date: Thu, 25 Sep 2025 03:47:55 +0200 Subject: [PATCH] accounts/keystore: use ticker to avoid timer allocations (#32732) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- accounts/keystore/keystore.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/accounts/keystore/keystore.go b/accounts/keystore/keystore.go index f9cc3edac8..3e4266924f 100644 --- a/accounts/keystore/keystore.go +++ b/accounts/keystore/keystore.go @@ -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()