aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-09-03 22:38:21 -0700
committerAdam Soltys <[email protected]>2026-09-03 22:38:21 -0700
commit94e837c04afd8c5c1257275cceccce85199151ec (patch)
tree48eaa9d697effc153b8baaf10a29de59c710df9d /src
parent3792c8791773d5201356d5fcc5f449ddd08e7a71 (diff)
downloadcoinosv3-94e837c04afd8c5c1257275cceccce85199151ec.tar.gz
coinosv3-94e837c04afd8c5c1257275cceccce85199151ec.zip
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
Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01MrkLsNScXe9b6BviUSdmMr
Diffstat (limited to 'src')
-rw-r--r--src/ark/manager.js15
1 files changed, 12 insertions, 3 deletions
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;