diff options
Diffstat (limited to 'lib/v3forward.ts')
| -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; |
