Struct tp_npos_elections::StakedAssignment[][src]

pub struct StakedAssignment<AccountId> {
    pub who: AccountId,
    pub distribution: Vec<(AccountId, ExtendedBalance)>,
}

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

impl<AccountId> StakedAssignment<AccountId>[src]

pub fn into_assignment<P: PerThing>(self) -> Assignment<AccountId, P> where
    AccountId: IdentifierT
[src]

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.

pub fn try_normalize(
    &mut self,
    stake: ExtendedBalance
) -> Result<(), &'static str>
[src]

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_.

pub fn total(&self) -> ExtendedBalance[src]

Get the total stake of this assignment (aka voter budget).

Trait Implementations

impl<AccountId: Clone> Clone for StakedAssignment<AccountId>[src]

impl<AccountId> Debug for StakedAssignment<AccountId> where
    AccountId: Debug
[src]

impl<AccountId> Decode for StakedAssignment<AccountId> where
    AccountId: Decode,
    AccountId: Decode,
    Vec<(AccountId, ExtendedBalance)>: Decode,
    Vec<(AccountId, ExtendedBalance)>: Decode
[src]

impl<AccountId: Default> Default for StakedAssignment<AccountId>[src]

impl<AccountId> Encode for StakedAssignment<AccountId> where
    AccountId: Encode,
    AccountId: Encode,
    Vec<(AccountId, ExtendedBalance)>: Encode,
    Vec<(AccountId, ExtendedBalance)>: Encode
[src]

impl<AccountId> EncodeLike<StakedAssignment<AccountId>> for StakedAssignment<AccountId> where
    AccountId: Encode,
    AccountId: Encode,
    Vec<(AccountId, ExtendedBalance)>: Encode,
    Vec<(AccountId, ExtendedBalance)>: Encode
[src]

impl<AccountId: Eq> Eq for StakedAssignment<AccountId>[src]

impl<AccountId: PartialEq> PartialEq<StakedAssignment<AccountId>> for StakedAssignment<AccountId>[src]

impl<AccountId> StructuralEq for StakedAssignment<AccountId>[src]

impl<AccountId> StructuralPartialEq for StakedAssignment<AccountId>[src]

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

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<S> Codec for S where
    S: Decode + Encode
[src]

impl<T> DecodeAll for T where
    T: Decode
[src]

impl<T> DecodeLimit for T where
    T: Decode
[src]

impl<T> Downcast for T where
    T: Any

impl<T> DowncastSync for T where
    T: Any + Send + Sync

impl<T> DynClone for T where
    T: Clone
[src]

impl<'_, '_, T> EncodeLike<&'_ &'_ T> for T where
    T: Encode
[src]

impl<'_, T> EncodeLike<&'_ T> for T where
    T: Encode
[src]

impl<'_, T> EncodeLike<&'_ mut T> for T where
    T: Encode
[src]

impl<T> EncodeLike<Arc<T>> for T where
    T: Encode
[src]

impl<T> EncodeLike<Box<T, Global>> for T where
    T: Encode
[src]

impl<'a, T> EncodeLike<Cow<'a, T>> for T where
    T: ToOwned + Encode
[src]

impl<T> EncodeLike<Rc<T>> for T where
    T: Encode
[src]

impl<T> From<T> for T[src]

impl<S> FullCodec for S where
    S: Decode + FullEncode
[src]

impl<S> FullEncode for S where
    S: Encode + EncodeLike<S>, 
[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, Outer> IsWrappedBy<Outer> for T where
    T: From<Outer>,
    Outer: AsRef<T> + AsMut<T> + From<T>, 
[src]

pub fn from_ref(outer: &Outer) -> &T[src]

Get a reference to the inner from the outer.

pub fn from_mut(outer: &mut Outer) -> &mut T[src]

Get a mutable reference to the inner from the outer.

impl<T> KeyedVec for T where
    T: Codec
[src]

impl<T> MaybeDebug for T where
    T: Debug

impl<T> MaybeRefUnwindSafe for T where
    T: RefUnwindSafe

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> SaturatedConversion for T[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<S, T> UncheckedInto<T> for S where
    T: UncheckedFrom<S>, 
[src]

impl<T, S> UniqueSaturatedInto<T> for S where
    T: Bounded,
    S: TryInto<T>, 
[src]

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,