pub struct NumShards { /* private fields */ }Expand description
Number of shards in the network
Implementations§
Source§impl NumShards
impl NumShards
Sourcepub const fn new(
intermediate_shards: NonZeroU16,
leaf_shards_per_intermediate_shard: NonZeroU16,
) -> Option<Self>
pub const fn new( intermediate_shards: NonZeroU16, leaf_shards_per_intermediate_shard: NonZeroU16, ) -> Option<Self>
Create a new instance from a number of intermediate shards and leaf shards per intermediate shard.
Returns None if inputs are invalid.
This is typically only necessary for low-level code.
Sourcepub const fn intermediate_shards(self) -> NonZeroU16
pub const fn intermediate_shards(self) -> NonZeroU16
The number of intermediate shards
Sourcepub const fn leaf_shards_per_intermediate_shard(self) -> NonZeroU16
pub const fn leaf_shards_per_intermediate_shard(self) -> NonZeroU16
The number of leaf shards per intermediate shard
Sourcepub const fn leaf_shards(&self) -> NonZeroU32
pub const fn leaf_shards(&self) -> NonZeroU32
Total number of leaf shards in the network
Sourcepub fn iter_intermediate_shards(&self) -> impl Iterator<Item = ShardIndex>
pub fn iter_intermediate_shards(&self) -> impl Iterator<Item = ShardIndex>
Iterator over all intermediate shards
Sourcepub fn iter_leaf_shards(&self) -> impl Iterator<Item = ShardIndex>
pub fn iter_leaf_shards(&self) -> impl Iterator<Item = ShardIndex>
Iterator over all intermediate shards
Sourcepub fn derive_shard_index(
&self,
public_key_hash: &Blake3Hash,
shard_commitments_root: &ShardCommitmentHash,
shard_membership_entropy: &ShardMembershipEntropy,
history_size: HistorySize,
) -> ShardIndex
pub fn derive_shard_index( &self, public_key_hash: &Blake3Hash, shard_commitments_root: &ShardCommitmentHash, shard_membership_entropy: &ShardMembershipEntropy, history_size: HistorySize, ) -> ShardIndex
Derive shard index that should be used in a solution
Sourcepub fn derive_shard_commitment_index(
&self,
public_key_hash: &Blake3Hash,
shard_commitments_root: &ShardCommitmentHash,
shard_membership_entropy: &ShardMembershipEntropy,
history_size: HistorySize,
) -> u32
pub fn derive_shard_commitment_index( &self, public_key_hash: &Blake3Hash, shard_commitments_root: &ShardCommitmentHash, shard_membership_entropy: &ShardMembershipEntropy, history_size: HistorySize, ) -> u32
Derive shard commitment index that should be used in a solution.
Returned index is always within 0..SolutionShardCommitment::NUM_LEAVES range.
Sourcepub fn derive_shard_index_and_shard_commitment_index(
&self,
public_key_hash: &Blake3Hash,
shard_commitments_root: &ShardCommitmentHash,
shard_membership_entropy: &ShardMembershipEntropy,
history_size: HistorySize,
) -> (ShardIndex, u32)
pub fn derive_shard_index_and_shard_commitment_index( &self, public_key_hash: &Blake3Hash, shard_commitments_root: &ShardCommitmentHash, shard_membership_entropy: &ShardMembershipEntropy, history_size: HistorySize, ) -> (ShardIndex, u32)
More efficient version of Self::derive_shard_index() and
Self::derive_shard_commitment_index() in a single call, see those functions for details
Trait Implementations§
Source§impl Decode for NumShards
Available on crate feature scale-codec only.
impl Decode for NumShards
scale-codec only.Source§fn decode<I: Input>(input: &mut I) -> Result<Self, Error>
fn decode<I: Input>(input: &mut I) -> Result<Self, Error>
§fn decode_into<I>(
input: &mut I,
dst: &mut MaybeUninit<Self>,
) -> Result<DecodeFinished, Error>where
I: Input,
fn decode_into<I>(
input: &mut I,
dst: &mut MaybeUninit<Self>,
) -> Result<DecodeFinished, Error>where
I: Input,
§fn skip<I>(input: &mut I) -> Result<(), Error>where
I: Input,
fn skip<I>(input: &mut I) -> Result<(), Error>where
I: Input,
§fn encoded_fixed_size() -> Option<usize>
fn encoded_fixed_size() -> Option<usize>
Source§impl<'de> Deserialize<'de> for NumShards
Available on crate feature serde only.
impl<'de> Deserialize<'de> for NumShards
serde only.Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Source§impl Encode for NumShards
impl Encode for NumShards
Source§fn size_hint(&self) -> usize
fn size_hint(&self) -> usize
Source§fn encode_to<__CodecOutputEdqy: Output + ?Sized>(
&self,
__codec_dest_edqy: &mut __CodecOutputEdqy,
)
fn encode_to<__CodecOutputEdqy: Output + ?Sized>( &self, __codec_dest_edqy: &mut __CodecOutputEdqy, )
§fn using_encoded<R, F>(&self, f: F) -> R
fn using_encoded<R, F>(&self, f: F) -> R
§fn encoded_size(&self) -> usize
fn encoded_size(&self) -> usize
Source§impl From<NumShards> for NumShardsUnchecked
impl From<NumShards> for NumShardsUnchecked
Source§impl MaxEncodedLen for NumShards
impl MaxEncodedLen for NumShards
Source§fn max_encoded_len() -> usize
fn max_encoded_len() -> usize
Source§impl TryFrom<NumShardsUnchecked> for NumShards
impl TryFrom<NumShardsUnchecked> for NumShards
impl Copy for NumShards
impl EncodeLike for NumShards
impl Eq for NumShards
impl StructuralPartialEq for NumShards
Auto Trait Implementations§
impl Freeze for NumShards
impl RefUnwindSafe for NumShards
impl Send for NumShards
impl Sync for NumShards
impl Unpin for NumShards
impl UnwindSafe for NumShards
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> DecodeAll for Twhere
T: Decode,
impl<T> DecodeAll for Twhere
T: Decode,
§fn decode_all(input: &mut &[u8]) -> Result<T, Error>
fn decode_all(input: &mut &[u8]) -> Result<T, Error>
Self and consume all of the given input data. Read more§impl<T> DecodeLimit for Twhere
T: Decode,
impl<T> DecodeLimit for Twhere
T: Decode,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more