dht search fixes

This commit is contained in:
Ultradesu
2026-07-17 00:00:05 +03:00
parent 555222d6d7
commit 9504ac23bf
3 changed files with 8 additions and 2 deletions
+4 -1
View File
@@ -228,12 +228,15 @@ impl Database {
/// Returns non-expired replicas stored under `key`, including tombstones
/// (they inform other peers about deletions). Capped at
/// [`MAX_RECORDS_PER_RESPONSE`].
/// [`MAX_RECORDS_PER_RESPONSE`] with a deterministic order (freshest
/// replicas first), so an overfull bucket always returns the same
/// subset instead of an arbitrary one.
pub async fn dht_records_by_key(&self, key: DhtKey, now_ms: u64) -> Result<Vec<StoredRecord>> {
self.call(move |conn| {
let mut stmt = conn.prepare(
"SELECT payload FROM dht_records
WHERE dht_key = ?1 AND expires_at_ms > ?2
ORDER BY expires_at_ms DESC, artist_id
LIMIT ?3",
)?;
let rows = stmt.query_map(