pub struct ShardConfig {
pub number_of_shards: u32,
pub mask_high: u32,
pub mask_low: u32,
}Expand description
Precomputed configuration for shard assignment.
Mirrors the Go multiShardCoordinator struct.
Fields§
§number_of_shards: u32Total number of regular shards (not counting the metachain).
mask_high: u32Bitmask using ceil(log2(number_of_shards)) bits.
mask_low: u32Bitmask using ceil(log2(number_of_shards)) - 1 bits (fallback).
Implementations§
Source§impl ShardConfig
impl ShardConfig
Sourcepub const THREE_SHARDS: ShardConfig
pub const THREE_SHARDS: ShardConfig
Pre-built configuration for the standard 3-shard setup used on MultiversX mainnet.
Sourcepub const fn new(number_of_shards: u32) -> Option<ShardConfig>
pub const fn new(number_of_shards: u32) -> Option<ShardConfig>
Creates a new ShardConfig for the given number of regular shards.
Returns None if number_of_shards is zero.
Sourcepub fn compute_id(&self, address: &Address) -> ShardId
pub fn compute_id(&self, address: &Address) -> ShardId
Calculates the shard for a given address.
Mirrors ComputeIdFromBytes in multiShardCoordinator.go.
Sourcepub fn same_shard(&self, a: &Address, b: &Address) -> bool
pub fn same_shard(&self, a: &Address, b: &Address) -> bool
Returns true if both addresses belong to the same shard.
Mirrors SameShard in multiShardCoordinator.go.
Trait Implementations§
Source§impl Clone for ShardConfig
impl Clone for ShardConfig
Source§fn clone(&self) -> ShardConfig
fn clone(&self) -> ShardConfig
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ShardConfig
impl Debug for ShardConfig
Source§impl PartialEq for ShardConfig
impl PartialEq for ShardConfig
Source§fn eq(&self, other: &ShardConfig) -> bool
fn eq(&self, other: &ShardConfig) -> bool
Tests for
self and other values to be equal, and is used by ==.impl Eq for ShardConfig
impl StructuralPartialEq for ShardConfig
Auto Trait Implementations§
impl Freeze for ShardConfig
impl RefUnwindSafe for ShardConfig
impl Send for ShardConfig
impl Sync for ShardConfig
impl Unpin for ShardConfig
impl UnsafeUnpin for ShardConfig
impl UnwindSafe for ShardConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more