Skip to content

Commit

Permalink
fix: make peer range query robust to existence of 5u8 key prefixes
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
black-puppydog committed Jul 21, 2024
1 parent bd7429c commit 185247e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions solar/src/storage/kv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 185247e

Please sign in to comment.