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

Function validate_put_routing

nodedb-cluster/src/distributed_array/handler.rs:179–191  ·  view source on GitHub ↗

Validate that a PUT request is routed to the correct shard. Returns `Ok(())` when routing is correct or when `prefix_bits == 0` (which means the request predates Hilbert routing and skips validation). Returns `Err(ClusterError::WrongOwner)` when the coordinator used a stale routing table; the coordinator should refresh and retry.

(req: &ArrayShardPutReq, local_vshard_id: u32)

Source from the content-addressed store, hash-verified

177/// Returns `Err(ClusterError::WrongOwner)` when the coordinator used a stale
178/// routing table; the coordinator should refresh and retry.
179fn validate_put_routing(req: &ArrayShardPutReq, local_vshard_id: u32) -> Result<()> {
180 if req.prefix_bits == 0 {
181 return Ok(());
182 }
183 let expected = array_vshard_for_tile(req.representative_hilbert_prefix, req.prefix_bits)?;
184 if expected != local_vshard_id {
185 return Err(ClusterError::WrongOwner {
186 vshard_id: local_vshard_id,
187 expected_owner_node: None,
188 });
189 }
190 Ok(())
191}
192
193/// Validate that a SLICE request is routed to the correct shard.
194///

Callers 1

handle_putFunction · 0.85

Calls 1

array_vshard_for_tileFunction · 0.85

Tested by

no test coverage detected