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

Function vshard_from_key

nodedb-cluster/src/array_routing.rs:53–59  ·  view source on GitHub ↗

Compute a vShard ID from an arbitrary byte key. Mirrors `VShardId::from_key` in `nodedb::types::id`.

(key: &[u8])

Source from the content-addressed store, hash-verified

51///
52/// Mirrors `VShardId::from_key` in `nodedb::types::id`.
53fn vshard_from_key(key: &[u8]) -> u32 {
54 let mut h: u64 = 0;
55 for &b in key {
56 h = h.wrapping_mul(0x100000001B3).wrapping_add(b as u64);
57 }
58 (h % VSHARD_COUNT as u64) as u32
59}
60
61// ─── Tile-id computation ──────────────────────────────────────────────────────
62

Callers 1

vshard_for_array_tileFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected