perf(net): hold wallet scans at connect, in the background and on tab entry

- Connect gate: after the node starts answering, wallet scans wait until the
  lock state is known and the node knows its tip (or the wallet has fewer
  than 500 transactions), at most 20 s. A node already behind latches the
  sync profile from the connect's getinfo. Meanwhile a list-only pass keeps
  the address list and the cached history up, and the session's first
  balance and per-address balances are read once even while catching up,
  so the wallet shows its last-synced values instead of 0.
- Background: minimized, hidden, or covered without focus (3 s debounce,
  any input cancels) polls only the chain state every 15 s. Wallet scans,
  the mining poll, price, nudges and auto-lock interaction tracking pause;
  auto-lock now fires while minimized. Leaving a held profile marks every
  timer due again.
- Tab entry marks the timers due instead of forcing scans; a stale list or
  a never-loaded history still loads on entry.
- The scan entry points own the hard gates, failed enumerations keep the
  previous lists behind a retry hold, and failed balance calls never
  overwrite known balances with 0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-09 11:06:34 -05:00
co-authored by Claude Opus 5.5
parent 323143e111
commit f86cc4d6b7
26 changed files with 1083 additions and 159 deletions
+17
View File
@@ -1622,6 +1622,7 @@ int main(int argc, char* argv[])
int dpiSettleFrames = 0;
SDL_DisplayID lastLoggedDisplay = 0; // [WINLOG] throttle: log MOVED only when the display changes
Uint64 minimizedLastTickMs = 0; // real-clock tick for the minimized "keep syncing" update
Uint64 backgroundSinceMs = 0; // when the window started to look backgrounded (0 = it doesn't)
{
float s = dragonx::ui::material::Typography::instance().getDpiScale();
int w = 0, h = 0;
@@ -1877,6 +1878,22 @@ int main(int argc, char* argv[])
}
}
// C134: the window is in the background when it is minimized, hidden, or covered while none of our
// windows has focus, for a few seconds with no input meanwhile. Focus loss alone never counts. The
// app then polls only the chain state; coming back is immediate.
{
const Uint64 nowMs = SDL_GetTicks();
const SDL_WindowFlags wf = SDL_GetWindowFlags(window);
const bool flagged = dragonx::services::windowLooksBackground(
(wf & SDL_WINDOW_MINIMIZED) != 0, (wf & SDL_WINDOW_HIDDEN) != 0,
(wf & SDL_WINDOW_OCCLUDED) != 0, SDL_GetKeyboardFocus() != nullptr);
if (!flagged) backgroundSinceMs = 0;
else if (backgroundSinceMs == 0) backgroundSinceMs = nowMs;
app.setWindowBackground(dragonx::services::isBackgroundWindow(
flagged, backgroundSinceMs != 0 ? (nowMs - backgroundSinceMs) / 1000.0 : 0.0,
lastInputMs != 0 ? (nowMs - lastInputMs) / 1000.0 : 1.0e9));
}
// Check if window is minimized
if (SDL_GetWindowFlags(window) & SDL_WINDOW_MINIMIZED) {
// Keep the wallet syncing while minimized: run the logic update (drains RPC results, ticks the