From e08096d9849513e1dd2341a55aa9835d81467284 Mon Sep 17 00:00:00 2001 From: moralpriest Date: Thu, 9 Jul 2026 02:50:56 -0600 Subject: [PATCH] fix(walletapi): simplify sync loop to zero-SCID-only polling Remove the test_connectivity() gate from the sync loop condition. IsDaemonOnline() is sufficient to determine connection state since it checks both WS and RPC client availability. Remove EntriesNative iteration from the sync loop. Previously the loop synced every known token SCID on each iteration, making many sequential RPC calls. Now it only syncs the native DERO (zero SCID). Token balances sync on demand when wallet API callers explicitly request them. This change prevents a concurrent map iteration and write panic when running SyncHistory as a background goroutine (which also accesses EntriesNative). --- walletapi/daemon_communication.go | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/walletapi/daemon_communication.go b/walletapi/daemon_communication.go index 2cffea05..8fd246a0 100644 --- a/walletapi/daemon_communication.go +++ b/walletapi/daemon_communication.go @@ -195,26 +195,18 @@ func (w *Wallet_Memory) sync_loop() { // w.db.Sync() } - if IsDaemonOnline() && test_connectivity() != nil { - time.Sleep(timeout) // wait 5 seconds + if !IsDaemonOnline() { + time.Sleep(timeout) // wait 3 seconds before retry continue } var zerohash crypto.Hash - if len(w.account.EntriesNative) == 0 { - if err := w.Sync_Wallet_Memory_With_Daemon(); err != nil { - logger.Error(err, "wallet syncing err") - } - } else { - for k := range w.account.EntriesNative { - err := w.Sync_Wallet_Memory_With_Daemon_internal(k) - if k == zerohash && err != nil { - logger.Error(err, "wallet syncing err") - } - } + // Sync zero SCID first so wallet height tracks daemon height. + if err := w.Sync_Wallet_Memory_With_Daemon_internal(zerohash); err != nil { + logger.Error(err, "wallet syncing err") } - - time.Sleep(timeout) // wait 5 seconds + // Token SCIDs sync on demand from wallet API callers. + time.Sleep(timeout) // wait 3 seconds for next block } }