diff options
| author | Adam Soltys <[email protected]> | 2026-11-20 08:11:44 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2026-11-20 08:11:44 -0700 |
| commit | c9f46cfb18bff34664fc5f65af70f31daa2d7d8d (patch) | |
| tree | e5dd15aebe9ce429a4746a334fc7847536b16b7d /src/nostr.js | |
| parent | 69997b1cf47470bbe098ca042b5b64ef5e8873e6 (diff) | |
| download | coinosv3-c9f46cfb18bff34664fc5f65af70f31daa2d7d8d.tar.gz coinosv3-c9f46cfb18bff34664fc5f65af70f31daa2d7d8d.zip | |
A profile's older posts load with no months skipped, and Primal's cache fills what relays have dropped. "I'm searching for his post he made about his Napster app. I feel like he should have more posts. Are we missing some?" (Adam, 2026-11-20, on Ben Arc's profile). The page asked for posts older than the oldest one on it. Relays each hold their own part of an author's history: his own relay's newest 30 ended on September 25, while relay.coinos.io held six stray copies reaching back to April, so the next page asked for posts before April and five months were never shown; the profile ended at 11 posts. Each relay's answer is now measured on its own. A page is taken as complete down to the newest floor among the sources that sent a full page; older strays wait and join the page that reaches them, and the profile ends only when no source has more. The posts around his Napstr launch (August 21 to 27) are on none of the relays the page asks, so Primal's cache is asked as one more source, posts and replies, each signature checked like a relay's. New profile-depth-test scrolls his profile back to the launch post (59 posts; 11 and a fail before). profile-pager, profile-stream, profile-replies, profile-repost, profile-page, profile-open and features-smoke pass; profile-feed-test fails with and without this change (it waits for a textarea on the restore screen).HEADmaster
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_01VMan6Upic5L6MMJzkTn8zg
Diffstat (limited to 'src/nostr.js')
| -rw-r--r-- | src/nostr.js | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/nostr.js b/src/nostr.js index 4b7f5c3..d2c9e44 100644 --- a/src/nostr.js +++ b/src/nostr.js @@ -602,6 +602,31 @@ export async function queryStreamOn(relays, filter, onEvent, maxWait = 1500) { }); } catch {} finally { await Promise.all(pending); } } +// queryStreamOn that also says how deep each relay's answer went: resolves +// with [{ url, n, min }] — how many events that relay sent for the filter and +// the oldest created_at among them. A caller paging backwards needs it: +// relays hold different parts of an author's history, and the oldest event +// of the merged answer may be one relay's stray copy from months earlier. +export async function queryDepthOn(relays, filter, onEvent, maxWait = 1500) { + probeRelays(relays); + const pending = [], stats = [], seen = new Set(); + try { + const live = readRelays(relays); + await Promise.all(live.map((url) => { + const s = { url, n: 0, min: Infinity }; + stats.push(s); + return askRelay(url, [filter], maxWait, (event) => { + if (!event) return; + s.n++; + if (event.created_at < s.min) s.min = event.created_at; + if (seen.has(event.id)) return; + seen.add(event.id); + pending.push(verifyOneAsync(event).then((ok) => ok && onEvent(event)).catch(() => {})); + }); + })); + } catch {} finally { await Promise.all(pending); } + return stats; +} export async function publishOn(relays, evt, { onauth = null, onrefused = null } = {}) { try { const live = liveRelays(relays); |
