mirror of
https://github.com/PR0M3TH3AN/Artstr-Studio.git
synced 2026-10-27 08:40:39 +00:00
Last Phase 3 polish piece per LINKED_DESIGNS_FEATURE.md §14. The cold-start path used to fire one parallel queryRelays per linked layer — a host with 20 distinct linked sources opened 20 sockets to each relay in the union. Now restoreAutosave issues one batched relay round-trip via the new linkedDesigns.prefetchBatch. Mechanics: 1. queryRelays accepts either a single filter object (existing callers) or an array of filters; arrays spread into the NIP-01 REQ after the sub id (OR semantics). One-line change at the send site; zero impact on existing call sites. 2. prefetchBatch(specs) skips anything already in the in-memory cache, inflight map, or disk cache — partial cache hits only fetch what's missing. Distinct address-coord refs are grouped by (kind, pubkey) into one filter each (#d set of dTags); pinned event ids collapse into a single ids-filter. Events bucket by id (for pinned matches) and by address coord with latest created_at wins (for ref matches). 3. restoreAutosave's per-spec resolveLinked loop becomes a single prefetchBatch call. The disk-cache pre-filter inside prefetchBatch means a reload of a previously-resolved host pays zero network cost; only newly-linked refs hit the wire. Per-layer resolveLinked calls in the renderer still work the way they did — this only changes the bulk warm-up path. Interactive adds (one new linked layer at a time) keep their single-filter fast path.