Skip to content

Commit 83dd66f

Browse files
fix(spv/storage): return None for heights below sync_base_height when base > 0 in MemoryStorageManager::get_header\n\nPrevents incorrect header lookup by avoiding implicit storage-index interpretation for absolute heights below the checkpoint base; aligns in-memory behavior with absolute height semantics.
1 parent 9887baa commit 83dd66f

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

dash-spv/src/storage/memory.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,13 +160,16 @@ impl StorageManager for MemoryStorageManager {
160160
_ => 0u32,
161161
};
162162

163-
// If height >= base, treat as absolute; else accept it as a storage index for compatibility
164-
let idx = if base > 0 && height >= base {
163+
// If a base is present and the requested height is below the base, no header exists.
164+
if base > 0 && height < base {
165+
return Ok(None);
166+
}
167+
// Map absolute height to storage index
168+
let idx = if base > 0 {
165169
(height - base) as usize
166170
} else {
167171
height as usize
168172
};
169-
170173
Ok(self.headers.get(idx).copied())
171174
}
172175

0 commit comments

Comments
 (0)