diff options
| author | Adam Soltys <[email protected]> | 2026-11-05 06:38:17 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2026-11-05 06:38:17 -0700 |
| commit | 589519f2556b2d434ed23f26c705df73b6149d7c (patch) | |
| tree | 0e23f7e973aef0a92bde11f45bee0195aa25f696 | |
| parent | c0a0f5c1ac6bbcfddc5ce15800483f1e2d7226a5 (diff) | |
| download | coinos-server-589519f2556b2d434ed23f26c705df73b6149d7c.tar.gz coinos-server-589519f2556b2d434ed23f26c705df73b6149d7c.zip | |
v3forward: a registrar 404 means nobody holds the name
The registrar answers 404 for a name that can't exist on v3, such as a
legacy username with spaces. Treat it as unheld, and cache it like one,
instead of logging a failed check on every receive.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
| -rw-r--r-- | lib/v3forward.ts | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/v3forward.ts b/lib/v3forward.ts index 9a263acd..34f634ef 100644 --- a/lib/v3forward.ts +++ b/lib/v3forward.ts @@ -34,6 +34,13 @@ async function v3Holder(username: string): Promise<{ pk: string | null; granted: if (hit && Date.now() - hit.at < (hit.pk ? 60_000 : 600_000)) return hit; const r = await fetch(`${NAMES_URL}/name/${encodeURIComponent(name)}?domain=${DOMAIN}`, { signal: AbortSignal.timeout(2000) }); + // 404 is the registrar's answer for a name that can't exist on v3 (a legacy + // username with spaces, say), so nobody holds it + if (r.status === 404) { + const none = { at: Date.now(), pk: null, granted: false }; + holderCache.set(name, none); + return none; + } if (!r.ok) throw new Error(`registrar said ${r.status}`); const body: any = await r.json(); const pk = body?.taken && typeof body.pubkey === "string" ? body.pubkey : null; |
