Skip to main content

shard_of_address_bytes

Function shard_of_address_bytes 

Source
pub fn shard_of_address_bytes(
    address: &[u8],
    num_shards: u32,
) -> Result<u32, CoreError>
Expand description

Determines shard ID from raw public key bytes (no bech32 decoding).

This implementation matches the Go reference: mx-chain-go/sharding/multiShardCoordinator.go Uses the same mask-based algorithm as ComputeShardID.

§Arguments

  • address - Raw 32-byte public key
  • num_shards - The total number of shards in the network

§Returns

The shard ID (0 to num_shards-1) or METACHAIN_SHARD_ID for metachain