mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2026-10-06 11:48:24 +00:00
Single-flight landed inside OkHttpLnurlEndpointResolver, which put the two halves of one mechanism — "resolve this URL exactly once" — in two modules. The flight map had to call LnurlForm.normalizeUrl purely to match a keying detail private to LnurlEndpointCache in quartz. Nothing documented or enforced that: if the cache changed its canonicalisation, the map would silently stop deduplicating and no test would fail. Move it onto the cache as getOrFetch(url, fetch). The key is now computed once and shared by the lookup, the flight map and the store, so they cannot disagree. Dedup also becomes process-wide, matching the resource it protects — a stranger's /.well-known/ endpoint — rather than being scoped to one resolver instance; clear() resets both maps. The resolver drops to a one-line delegation and keeps only the HTTP half. Same shape as NwcInfoCache, which already pairs a cache with an in-flight map and an injected fetch. Mechanism tests move to quartz beside the cache, using delay() rather than a blocking sleep. The commons test keeps the one claim it uniquely makes: that the resolver really routes through the cache over a real OkHttp client. No behaviour change. Verified by mutation: removing single-flight, keying the flight map on the raw URL, never releasing the slot, and making the resolver bypass the cache each fail exactly the test that covers them.