Skip to content

Commit 21b607f

Browse files
CopilotSteake
andcommitted
Add clarifying comments and fix documentation inconsistency
Co-authored-by: Steake <530040+Steake@users.noreply.github.com>
1 parent c906170 commit 21b607f

3 files changed

Lines changed: 9 additions & 4 deletions

File tree

crates/bitcell-state/src/storage.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,11 @@ impl StorageManager {
254254
continue; // Invalid key format (too short)
255255
}
256256

257-
// Check if sender portion matches exactly
258-
// This ensures we don't match longer senders that share a prefix
257+
// Check if sender portion matches exactly.
258+
// This break is intentional: RocksDB's prefix_iterator may return keys for longer
259+
// senders that share the same initial bytes (e.g., when searching for "abc", it
260+
// might also return keys starting with "abcd"). We break as soon as the prefix
261+
// no longer matches exactly to avoid returning transactions from other senders.
259262
if &key[0..sender.len()] != sender {
260263
break; // No longer matching our sender prefix
261264
}

crates/bitcell-state/tests/storage_persistence_test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ fn test_snapshot_based_recovery() {
228228
assert!(header.is_none(), "Block {} should have been pruned", height);
229229
}
230230

231-
// Recent blocks should still exist
231+
// Recent blocks should still exist (blocks 799-999 since we stored 0-999)
232232
for height in 799..1000 {
233233
let header = storage.get_header_by_height(height).unwrap();
234234
assert!(header.is_some(), "Block {} should not have been pruned", height);

docs/STORAGE.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,10 +230,12 @@ let stats = storage.prune_old_blocks_production(
230230
)?;
231231

232232
println!("Deleted {} blocks", stats.blocks_deleted);
233-
println!("Deleted {} transactions", stats.transactions_deleted);
233+
println!("Deleted ~{} transactions (approximate)", stats.transactions_deleted);
234234
println!("Archived: {}", stats.archived);
235235
```
236236

237+
> **Note:** Transaction deletion count is currently approximate as the pruning implementation doesn't fully track individual transaction deletions.
238+
237239
## Integration with StateManager
238240

239241
The `StateManager` can use persistent storage:

0 commit comments

Comments
 (0)