Skip to main content

height_key

Function height_key 

Source
pub fn height_key(height: u64) -> [u8; 8]
Expand description

Encode a chain height as an 8-byte big-endian key for crate::constants::CF_CANONICAL (KEY-002).

Sort invariant: For a < b, height_key(a).as_slice() < height_key(b).as_slice() in bytewise order, so RocksDB’s default comparator iterates heights in ascending numeric order (required for range scans and reorg walks).

Decode: Use decode_height_key after reads (symmetric to decode_epoch_key for checkpoints).

Fixed width: Always exactly 8 bytes — no VLQ or length prefix.