uses Option<Slot> for SlotMeta.parent_slot (#21808)

SlotMeta.parent_slot for the head of a detached chain of slots is
unknown and that is indicated by u64::MAX which lacks type-safety:
https://github.com/solana-labs/solana/blob/6c108c8fc/ledger/src/blockstore_meta.rs#L203-L205

The commit changes the type to Option<Slot>. Backward compatibility is
maintained by customizing serde serialize/deserialize implementations.
This commit is contained in:
behzad nouri
2021-12-14 18:57:11 +00:00
committed by GitHub
parent d13a5056f1
commit 8d980f07ba
7 changed files with 79 additions and 75 deletions

View File

@@ -2761,7 +2761,7 @@ fn test_no_voting() {
let meta = ledger.meta(i as u64).unwrap().unwrap();
let parent = meta.parent_slot;
let expected_parent = i.saturating_sub(1);
assert_eq!(parent, expected_parent as u64);
assert_eq!(parent, Some(expected_parent as u64));
}
}