From 185247ead3462f3d46830889b063b4fac6a7ea5a Mon Sep 17 00:00:00 2001 From: Daan Wynen Date: Sun, 21 Jul 2024 14:55:04 +0200 Subject: [PATCH] fix: make peer range query robust to existence of 5u8 key prefixes The open range `scan_peer_key..` we were passing into `db.range()` was returning all keys that start with `4u8` *or higher*. Simple fix: give `5u8` as the upper bound of the query. It's worth noting that the same should apply to the blob range queries, I'll try to make a commit for those next. --- solar/src/storage/kv.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/solar/src/storage/kv.rs b/solar/src/storage/kv.rs index b563be1..83cee57 100644 --- a/solar/src/storage/kv.rs +++ b/solar/src/storage/kv.rs @@ -226,8 +226,9 @@ impl KvStorage { let mut peers = Vec::new(); // Use the generic peer prefix to return an iterator over all peers. - let scan_peer_key: &[u8] = &[PREFIX_PEER]; - for peer in db.range(scan_peer_key..) { + let scan_peer_key_start: &[u8] = &[PREFIX_PEER]; + let scan_peer_key_end: &[u8] = &[PREFIX_PEER + 1]; + for peer in db.range(scan_peer_key_start..scan_peer_key_end) { let (peer_key, _) = peer?; // Drop the prefix byte and convert the remaining bytes to // a string.