Skip to main content

could_follow

Function could_follow 

Source
fn could_follow(bytes: &[u8], last_seq: u64, capacity: u64) -> bool
Expand description

Whether bytes could start a frame written after last_seq, judged on the header alone, before any CRC (the scan’s search for a later record). Its length fits, and its seq is past last_seq by no more than the number of frames capacity holds: every record this segment can contain is within that, and leftovers from before a compaction carry seqs at or below the checkpoint’s. And its payload starts as every appended one does, with the entry’s own seq ({"seq":<seq>,, Entry’s first field): at a misaligned offset inside a leftover frame, a length and a seq can both look plausible, but not that too. Without these the search ran a CRC over the claimed length at every byte offset, quadratic in the store after a compaction (stale seqs and hashes read as plausible lengths).