MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / hlc_from_key

Function hlc_from_key

nodedb/src/control/array_sync/op_log.rs:53–60  ·  view source on GitHub ↗

Parse the HLC from the tail of a composite key. Returns `None` if the key is shorter than `prefix_len + 18`.

(key: &[u8], prefix_len: usize)

Source from the content-addressed store, hash-verified

51///
52/// Returns `None` if the key is shorter than `prefix_len + 18`.
53fn hlc_from_key(key: &[u8], prefix_len: usize) -> Option<Hlc> {
54 if key.len() < prefix_len + 18 {
55 return None;
56 }
57 let start = key.len() - 18;
58 let hlc_bytes: [u8; 18] = key[start..].try_into().ok()?;
59 Some(Hlc::from_bytes(&hlc_bytes))
60}
61
62/// Persistent array op-log backed by a dedicated redb database.
63///

Callers 3

scan_fromMethod · 0.70
scan_rangeMethod · 0.70
drop_belowMethod · 0.70

Calls 2

lenMethod · 0.45
okMethod · 0.45

Tested by

no test coverage detected