#[repr(C)]pub struct SolutionRange(/* private fields */);
Expand description
Solution range
Implementations§
Source§impl SolutionRange
impl SolutionRange
Sourcepub fn from_bytes(bytes: [u8; 8]) -> Self
pub fn from_bytes(bytes: [u8; 8]) -> Self
Create a new instance from bytes
Sourcepub const fn from_pieces(pieces: u64, slot_probability: (u64, u64)) -> Self
pub const fn from_pieces(pieces: u64, slot_probability: (u64, u64)) -> Self
Computes the following:
MAX * slot_probability / chunks * s_buckets / pieces
Sourcepub const fn to_pieces(self, slot_probability: (u64, u64)) -> u64
pub const fn to_pieces(self, slot_probability: (u64, u64)) -> u64
Computes the following:
MAX * slot_probability / chunks * s_buckets / solution_range
Sourcepub const fn bidirectional_distance(self, other: Self) -> SolutionDistance
pub const fn bidirectional_distance(self, other: Self) -> SolutionDistance
Bidirectional distance between two solution ranges
Sourcepub fn derive_next(
self,
start_slot: SlotNumber,
current_slot: SlotNumber,
slot_probability: (u64, u64),
era_duration: BlockNumber,
) -> Self
pub fn derive_next( self, start_slot: SlotNumber, current_slot: SlotNumber, slot_probability: (u64, u64), era_duration: BlockNumber, ) -> Self
Derives next solution range based on the total era slots and slot probability
Trait Implementations§
Source§impl Add for SolutionRange
impl Add for SolutionRange
Source§type Output = SolutionRange
type Output = SolutionRange
The resulting type after applying the
+
operator.Source§fn add(self, rhs: SolutionRange) -> SolutionRange
fn add(self, rhs: SolutionRange) -> SolutionRange
Performs the
+
operation. Read moreSource§impl AddAssign for SolutionRange
impl AddAssign for SolutionRange
Source§fn add_assign(&mut self, rhs: SolutionRange)
fn add_assign(&mut self, rhs: SolutionRange)
Performs the
+=
operation. Read moreSource§impl Clone for SolutionRange
impl Clone for SolutionRange
Source§fn clone(&self) -> SolutionRange
fn clone(&self) -> SolutionRange
Returns a copy of the value. Read more
1.0.0 · 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 SolutionRange
impl Debug for SolutionRange
Source§impl Decode for SolutionRange
impl Decode for SolutionRange
Source§fn decode<__CodecInputEdqy: Input>(
__codec_input_edqy: &mut __CodecInputEdqy,
) -> Result<Self, Error>
fn decode<__CodecInputEdqy: Input>( __codec_input_edqy: &mut __CodecInputEdqy, ) -> Result<Self, Error>
Attempt to deserialise the value from input.
§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,
Attempt to deserialize the value from input into a pre-allocated piece of memory. Read more
§fn skip<I>(input: &mut I) -> Result<(), Error>where
I: Input,
fn skip<I>(input: &mut I) -> Result<(), Error>where
I: Input,
Attempt to skip the encoded value from input. Read more
§fn encoded_fixed_size() -> Option<usize>
fn encoded_fixed_size() -> Option<usize>
Returns the fixed encoded size of the type. Read more
Source§impl Default for SolutionRange
impl Default for SolutionRange
Source§fn default() -> SolutionRange
fn default() -> SolutionRange
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for SolutionRange
impl<'de> Deserialize<'de> for SolutionRange
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>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Display for SolutionRange
impl Display for SolutionRange
Source§impl Encode for SolutionRange
impl Encode for SolutionRange
Source§fn size_hint(&self) -> usize
fn size_hint(&self) -> usize
If possible give a hint of expected size of the encoding. Read more
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, )
Convert self to a slice and append it to the destination.
Source§fn using_encoded<__CodecOutputReturn, __CodecUsingEncodedCallback: FnOnce(&[u8]) -> __CodecOutputReturn>(
&self,
f: __CodecUsingEncodedCallback,
) -> __CodecOutputReturn
fn using_encoded<__CodecOutputReturn, __CodecUsingEncodedCallback: FnOnce(&[u8]) -> __CodecOutputReturn>( &self, f: __CodecUsingEncodedCallback, ) -> __CodecOutputReturn
Convert self to a slice and then invoke the given closure with it.
§fn encoded_size(&self) -> usize
fn encoded_size(&self) -> usize
Calculates the encoded size. Read more
Source§impl From<SolutionRange> for u64
impl From<SolutionRange> for u64
Source§fn from(value: SolutionRange) -> Self
fn from(value: SolutionRange) -> Self
Converts to this type from the input type.
Source§impl From<u64> for SolutionRange
impl From<u64> for SolutionRange
Source§impl Hash for SolutionRange
impl Hash for SolutionRange
Source§impl MaxEncodedLen for SolutionRange
impl MaxEncodedLen for SolutionRange
Source§fn max_encoded_len() -> usize
fn max_encoded_len() -> usize
Upper bound, in bytes, of the maximum encoded size of this item.
Source§impl Ord for SolutionRange
impl Ord for SolutionRange
Source§fn cmp(&self, other: &SolutionRange) -> Ordering
fn cmp(&self, other: &SolutionRange) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for SolutionRange
impl PartialEq for SolutionRange
Source§impl PartialOrd for SolutionRange
impl PartialOrd for SolutionRange
Source§impl Serialize for SolutionRange
impl Serialize for SolutionRange
Source§impl Sub for SolutionRange
impl Sub for SolutionRange
Source§type Output = SolutionRange
type Output = SolutionRange
The resulting type after applying the
-
operator.Source§fn sub(self, rhs: SolutionRange) -> SolutionRange
fn sub(self, rhs: SolutionRange) -> SolutionRange
Performs the
-
operation. Read moreSource§impl SubAssign for SolutionRange
impl SubAssign for SolutionRange
Source§fn sub_assign(&mut self, rhs: SolutionRange)
fn sub_assign(&mut self, rhs: SolutionRange)
Performs the
-=
operation. Read moreSource§impl TypeInfo for SolutionRange
impl TypeInfo for SolutionRange
impl Copy for SolutionRange
impl EncodeLike for SolutionRange
impl Eq for SolutionRange
impl StructuralPartialEq for SolutionRange
Auto Trait Implementations§
impl Freeze for SolutionRange
impl RefUnwindSafe for SolutionRange
impl Send for SolutionRange
impl Sync for SolutionRange
impl Unpin for SolutionRange
impl UnwindSafe for SolutionRange
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
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>
Decode
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>
Converts
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>
Converts
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