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: AccountIdVoter’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>where
AccountId: Decode,
Vec<(AccountId, ExtendedBalance)>: Decode,
impl<AccountId> Decode for StakedAssignment<AccountId>where
AccountId: Decode,
Vec<(AccountId, ExtendedBalance)>: Decode,
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>where
AccountId: Encode,
Vec<(AccountId, ExtendedBalance)>: Encode,
impl<AccountId> Encode for StakedAssignment<AccountId>where
AccountId: Encode,
Vec<(AccountId, ExtendedBalance)>: Encode,
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) -> Rwhere
F: FnOnce(&[u8]) -> R,
fn using_encoded<R, F>(&self, f: F) -> Rwhere
F: FnOnce(&[u8]) -> R,
source§fn encoded_size(&self) -> usize
fn encoded_size(&self) -> usize
source§impl<AccountId: PartialEq> PartialEq<StakedAssignment<AccountId>> for StakedAssignment<AccountId>
impl<AccountId: PartialEq> PartialEq<StakedAssignment<AccountId>> for StakedAssignment<AccountId>
source§fn eq(&self, other: &StakedAssignment<AccountId>) -> bool
fn eq(&self, other: &StakedAssignment<AccountId>) -> bool
impl<AccountId> EncodeLike<StakedAssignment<AccountId>> for StakedAssignment<AccountId>where
AccountId: Encode,
Vec<(AccountId, ExtendedBalance)>: Encode,
impl<AccountId: Eq> Eq for StakedAssignment<AccountId>
impl<AccountId> StructuralEq for StakedAssignment<AccountId>
impl<AccountId> StructuralPartialEq for StakedAssignment<AccountId>
Auto Trait Implementations§
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> 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<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
source§fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait. Read moresource§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait. Read moresource§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s. Read moresource§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s. Read moresource§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.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, Outer> IsWrappedBy<Outer> for Twhere
Outer: AsRef<T> + AsMut<T> + From<T>,
T: From<Outer>,
impl<T, Outer> IsWrappedBy<Outer> for Twhere
Outer: AsRef<T> + AsMut<T> + From<T>,
T: From<Outer>,
source§impl<T> Pointable for T
impl<T> Pointable 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 Swhere
T: Bounded,
S: TryInto<T>,
impl<T, S> UniqueSaturatedInto<T> for Swhere
T: Bounded,
S: TryInto<T>,
source§fn unique_saturated_into(self) -> T
fn unique_saturated_into(self) -> T
T.