Struct sp_npos_elections::StakedAssignment
source · pub struct StakedAssignment<AccountId> {
pub who: AccountId,
pub distribution: Vec<(AccountId, ExtendedBalance)>,
}
Expand description
A voter’s stake assignment among a set of targets, represented as absolute values in the scale
of ExtendedBalance
.
Fields§
§who: AccountId
Voter’s identifier
distribution: Vec<(AccountId, ExtendedBalance)>
The distribution of the voter’s stake.
Implementations§
source§impl<AccountId> StakedAssignment<AccountId>
impl<AccountId> StakedAssignment<AccountId>
sourcepub fn into_assignment<P: PerThing>(self) -> Assignment<AccountId, P>where
AccountId: IdentifierT,
pub fn into_assignment<P: PerThing>(self) -> Assignment<AccountId, P>where
AccountId: IdentifierT,
Converts self into the normal Assignment
type.
NOTE: This will always round down, and thus the results might be less than a full 100% P
.
Use a normalization post-processing to fix this. The data type returned here will
potentially get used to create a compact type; a compact type requires sum of ratios to be
less than 100% upon un-compacting.
If an edge stake is so small that it cannot be represented in T
, it is ignored. This edge
can never be re-created and does not mean anything useful anymore.
sourcepub fn try_normalize(
&mut self,
stake: ExtendedBalance
) -> Result<(), &'static str>
pub fn try_normalize( &mut self, stake: ExtendedBalance ) -> Result<(), &'static str>
Try and normalize this assignment.
If Ok(())
is returned, then the assignment MUST have been successfully normalized to
stake
.
NOTE: current implementation of .normalize
is almost safe to expect()
upon. The only
error case is when the input cannot fit in T
, or the sum of input cannot fit in T
.
Sadly, both of these are dependent upon the implementation of VoteLimit
, i.e. the limit of
edges per voter which is enforced from upstream. Hence, at this crate, we prefer returning a
result and a use the name prefix try_
.
sourcepub fn total(&self) -> ExtendedBalance
pub fn total(&self) -> ExtendedBalance
Get the total stake of this assignment (aka voter budget).
Trait Implementations§
source§impl<AccountId: Clone> Clone for StakedAssignment<AccountId>
impl<AccountId: Clone> Clone for StakedAssignment<AccountId>
source§fn clone(&self) -> StakedAssignment<AccountId>
fn clone(&self) -> StakedAssignment<AccountId>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<AccountId> Debug for StakedAssignment<AccountId>where
AccountId: Debug,
impl<AccountId> Debug for StakedAssignment<AccountId>where
AccountId: Debug,
source§impl<AccountId> Decode for StakedAssignment<AccountId>
impl<AccountId> Decode for StakedAssignment<AccountId>
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>
source§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,
source§impl<AccountId: Default> Default for StakedAssignment<AccountId>
impl<AccountId: Default> Default for StakedAssignment<AccountId>
source§fn default() -> StakedAssignment<AccountId>
fn default() -> StakedAssignment<AccountId>
source§impl<AccountId> Encode for StakedAssignment<AccountId>
impl<AccountId> Encode for StakedAssignment<AccountId>
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 )
source§fn using_encoded<R, F>(&self, f: F) -> R
fn using_encoded<R, F>(&self, f: F) -> R
source§fn encoded_size(&self) -> usize
fn encoded_size(&self) -> usize
source§impl<AccountId: PartialEq> PartialEq for StakedAssignment<AccountId>
impl<AccountId: PartialEq> PartialEq for StakedAssignment<AccountId>
source§fn eq(&self, other: &StakedAssignment<AccountId>) -> bool
fn eq(&self, other: &StakedAssignment<AccountId>) -> bool
self
and other
values to be equal, and is used
by ==
.impl<AccountId> EncodeLike for StakedAssignment<AccountId>
impl<AccountId: Eq> Eq for StakedAssignment<AccountId>
impl<AccountId> StructuralPartialEq for StakedAssignment<AccountId>
Auto Trait Implementations§
impl<AccountId> Freeze for StakedAssignment<AccountId>where
AccountId: Freeze,
impl<AccountId> RefUnwindSafe for StakedAssignment<AccountId>where
AccountId: RefUnwindSafe,
impl<AccountId> Send for StakedAssignment<AccountId>where
AccountId: Send,
impl<AccountId> Sync for StakedAssignment<AccountId>where
AccountId: Sync,
impl<AccountId> Unpin for StakedAssignment<AccountId>where
AccountId: Unpin,
impl<AccountId> UnwindSafe for StakedAssignment<AccountId>where
AccountId: UnwindSafe,
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> CheckedConversion for T
impl<T> CheckedConversion for T
source§impl<T> DecodeLimit for Twhere
T: Decode,
impl<T> DecodeLimit for Twhere
T: Decode,
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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 moresource§impl<T, Outer> IsWrappedBy<Outer> for T
impl<T, Outer> IsWrappedBy<Outer> for T
source§impl<T> SaturatedConversion for T
impl<T> SaturatedConversion for T
source§fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
source§fn saturated_into<T>(self) -> Twhere
Self: UniqueSaturatedInto<T>,
fn saturated_into<T>(self) -> Twhere
Self: UniqueSaturatedInto<T>,
T
. Read moresource§impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
source§fn unchecked_into(self) -> T
fn unchecked_into(self) -> T
unchecked_from
.source§impl<T, S> UniqueSaturatedInto<T> for S
impl<T, S> UniqueSaturatedInto<T> for S
source§fn unique_saturated_into(self) -> T
fn unique_saturated_into(self) -> T
T
.