Skip to main content

select_shard

Function select_shard 

Source
pub fn select_shard(last_byte: u8, num_shards: u32) -> u32
Expand description

Computes the shard ID from the last byte of an address.

Uses optimized bit masking for the common case of 3 shards (instead of modulo).

§Arguments

  • last_byte - The last byte of the address
  • num_shards - The total number of shards in the network

§Returns

The shard ID (0 to num_shards-1)