MCPcopy Create free account
hub / github.com/clockworklabs/SpacetimeDB / validate_commit_header

Function validate_commit_header

crates/commitlog/src/segment.rs:516–530  ·  view source on GitHub ↗

Try to extract the commit header from the asked position without advancing seek. `IndexFileMut` fsync asynchoronously, which makes it important for reader to verify its entry

(
    mut reader: &mut Reader,
    byte_offset: u64,
)

Source from the content-addressed store, hash-verified

514/// Try to extract the commit header from the asked position without advancing seek.
515/// `IndexFileMut` fsync asynchoronously, which makes it important for reader to verify its entry
516pub fn validate_commit_header<Reader: io::Read + io::Seek>(
517 mut reader: &mut Reader,
518 byte_offset: u64,
519) -> io::Result<commit::Header> {
520 let pos = reader.stream_position()?;
521 reader.seek(SeekFrom::Start(byte_offset))?;
522
523 let hdr = commit::Header::decode(&mut reader)
524 .and_then(|hdr| hdr.ok_or_else(|| io::Error::new(ErrorKind::UnexpectedEof, "unexpected EOF")));
525
526 // Restore the original position
527 reader.seek(SeekFrom::Start(pos))?;
528
529 hdr
530}
531
532/// Pair of transaction offset and payload.
533///

Callers 1

seek_to_offsetFunction · 0.85

Calls 3

decodeFunction · 0.85
newFunction · 0.50
seekMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…