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

Function replica_id_from_key

nodedb/src/control/array_sync/ack_registry.rs:57–68  ·  view source on GitHub ↗

Parse the replica_id from the tail of a composite key.

(key: &[u8])

Source from the content-addressed store, hash-verified

55
56/// Parse the replica_id from the tail of a composite key.
57fn replica_id_from_key(key: &[u8]) -> Option<u64> {
58 if key.len() < 9 {
59 return None;
60 }
61 let name_len = key[0] as usize;
62 let replica_start = 1 + name_len;
63 if key.len() < replica_start + 8 {
64 return None;
65 }
66 let bytes: [u8; 8] = key[replica_start..replica_start + 8].try_into().ok()?;
67 Some(u64::from_be_bytes(bytes))
68}
69
70/// Registry tracking the latest acknowledged HLC per `(array, replica_id)`.
71///

Callers 1

load_cacheMethod · 0.85

Calls 2

lenMethod · 0.45
okMethod · 0.45

Tested by

no test coverage detected