cache: include nar_url in ListRecentRoutes; test expired TTL in GetRouteByNarURL

Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: I952d08726f34d0d9b7c4c1880d60222c6a6a6964
This commit is contained in:
raf 2026-03-06 22:00:29 +03:00
commit ded9b6d464
Signed by: NotAShelf
GPG key ID: 29D95B64378DB4BF
2 changed files with 20 additions and 2 deletions

View file

@ -197,7 +197,7 @@ func (d *DB) ExpireOldRoutes() error {
// Returns up to n non-expired routes ordered by most-recently-verified.
func (d *DB) ListRecentRoutes(n int) ([]RouteEntry, error) {
rows, err := d.db.Query(`
SELECT store_path, upstream_url, latency_ema, last_verified, ttl, nar_hash, nar_size
SELECT store_path, upstream_url, latency_ema, last_verified, ttl, nar_hash, nar_size, nar_url
FROM routes WHERE ttl > ? ORDER BY last_verified DESC LIMIT ?`,
time.Now().Unix(), n)
if err != nil {
@ -210,7 +210,7 @@ func (d *DB) ListRecentRoutes(n int) ([]RouteEntry, error) {
var lastVerifiedUnix, ttlUnix int64
if err := rows.Scan(
&e.StorePath, &e.UpstreamURL, &e.LatencyEMA,
&lastVerifiedUnix, &ttlUnix, &e.NarHash, &e.NarSize,
&lastVerifiedUnix, &ttlUnix, &e.NarHash, &e.NarSize, &e.NarURL,
); err != nil {
return nil, err
}