Compute a vShard ID from an arbitrary byte key. Mirrors `VShardId::from_key` in `nodedb::types::id`.
(key: &[u8])
| 51 | /// |
| 52 | /// Mirrors `VShardId::from_key` in `nodedb::types::id`. |
| 53 | fn 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 |
no outgoing calls
no test coverage detected