From 94e837c04afd8c5c1257275cceccce85199151ec Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Thu, 3 Sep 2026 22:38:21 -0700 Subject: Ark reconcile signs in time-sliced batches: it built a status query (schnorr sign + vtxo decode, real secp256k1) for every spendable coin in one synchronous map — a ~100ms+ EC burst on boot, the local work blocking a carousel drag right after a refresh (community/DM wraps arrive over the network later; this fires immediately on init). The requests now kick off in ≤6ms slices that yield; network calls still overlap MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01MrkLsNScXe9b6BviUSdmMr --- src/ark/manager.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'src/ark/manager.js') diff --git a/src/ark/manager.js b/src/ark/manager.js index 4e9a62c..a443370 100644 --- a/src/ark/manager.js +++ b/src/ark/manager.js @@ -502,9 +502,18 @@ export class ArkManager { // but never mint it, and the signed bytes stay held for unilateral exit. async reconcile() { const candidates = this.state.vtxos.filter((v) => v.state === 'spendable'); - const states = await Promise.all(candidates.map((v) => - getVtxoStatus(this.arkUrl, this._decoded(v).point.raw, this._keyForVtxo(v).privkey) - .catch(() => null))); // unreachable/erroring server changes nothing + // Each status query signs a challenge (schnorr) and may decode the vtxo — + // real secp256k1 work. Building them all in one synchronous map was a + // ~100ms+ EC burst on boot (dozens of coins), the stall behind a carousel + // drag right after a refresh. Kick the requests off in time-sliced batches + // so the signing spreads across frames; the network calls still overlap. + const pending = []; + let t0 = performance.now(); + for (const v of candidates) { + pending.push(getVtxoStatus(this.arkUrl, this._decoded(v).point.raw, this._keyForVtxo(v).privkey).catch(() => null)); + if (performance.now() - t0 > 6) { await new Promise((r) => setTimeout(r)); t0 = performance.now(); } + } + const states = await Promise.all(pending); // unreachable/erroring server changes nothing let changed = false; candidates.forEach((v, i) => { if (states[i] !== VTXO_STATE_SPENT) return; -- cgit v1.2.3