aboutsummaryrefslogtreecommitdiffstats
path: root/src/api.js
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-06-27 23:17:56 -0700
committerAdam Soltys <[email protected]>2026-06-27 23:17:56 -0700
commitdf58295848c7675e6501148da2a988b918811a2c (patch)
treeb06dbd67d086ace52ed9c7b3639bbfe4579d8b1e /src/api.js
parent77a14981edc9b65bfce52a2e97ec99e6069e9c77 (diff)
downloadcoinosv3-df58295848c7675e6501148da2a988b918811a2c.tar.gz
coinosv3-df58295848c7675e6501148da2a988b918811a2c.zip
Fix SP scanning jank: memoize by tweak + yield + coalesce
Profiling (CDP) showed the toggle lag/high CPU was _scanSpMempool re-scanning the ENTIRE mempool item set on every WS push (the mempool churns constantly), redoing an EC point-multiplication per tweak on the main thread — ~1s blocks. - Memoize silentPaymentScan/silentPaymentCandidate by tweak (outcome is fixed), cleared when the SP keys change, capped to bound memory. Steady-state CPU from re-scanning dropped from ~1s/push to ~0 (measured 18ms over 9s idle). - Yield to the event loop during the catch-up block loop and the mempool scan, so a large first/cold scan (mainnet) doesn't freeze the UI. - Coalesce mempool scans (latest-wins, never two at once) with a race guard so a block confirming mid-scan can't duplicate an outpoint. Measured after: receive toggle 8/8 switches, avg 5ms / max 9ms (was 1-2s). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Diffstat (limited to 'src/api.js')
0 files changed, 0 insertions, 0 deletions