Struct sp_npos_elections::Voter
source · pub struct Voter<AccountId> { /* private fields */ }
Expand description
A voter entity.
Implementations§
source§impl<AccountId: IdentifierT> Voter<AccountId>
impl<AccountId: IdentifierT> Voter<AccountId>
sourcepub fn votes_for(&self, target: &AccountId) -> bool
pub fn votes_for(&self, target: &AccountId) -> bool
Returns true
if self
votes for target
.
Note that this does not take into account if target
is elected (i.e. is active) or not.
sourcepub fn into_assignment<P: PerThing>(self) -> Option<Assignment<AccountId, P>>
pub fn into_assignment<P: PerThing>(self) -> Option<Assignment<AccountId, P>>
Returns none if this voter does not have any non-zero distributions.
Note that this might create un-normalized assignments, due to accuracy loss of P
. Call
site might compensate by calling normalize()
on the returned Assignment
as a
post-processing.
sourcepub fn try_normalize(&mut self) -> Result<(), &'static str>
pub fn try_normalize(&mut self) -> Result<(), &'static str>
Try and normalize the votes of self.
If the normalization is successful then Ok(())
is returned.
Note that this will not distinguish between elected and unelected edges. Thus, it should only be called on a voter who has already been reduced to only elected edges.
Errors
This will return only if the internal normalize
fails. This can happen if the sum of the
weights exceeds ExtendedBalance::max_value()
.
sourcepub fn try_normalize_elected(&mut self) -> Result<(), &'static str>
pub fn try_normalize_elected(&mut self) -> Result<(), &'static str>
Same as Self::try_normalize
but the normalization is only limited between elected edges.
sourcepub fn budget(&self) -> ExtendedBalance
pub fn budget(&self) -> ExtendedBalance
This voter’s budget.
Trait Implementations§
source§impl<A: IdentifierT> Debug for Voter<A>
impl<A: IdentifierT> Debug for Voter<A>
Auto Trait Implementations§
impl<AccountId> !RefUnwindSafe for Voter<AccountId>
impl<AccountId> !Send for Voter<AccountId>
impl<AccountId> !Sync for Voter<AccountId>
impl<AccountId> Unpin for Voter<AccountId>where AccountId: Unpin,
impl<AccountId> !UnwindSafe for Voter<AccountId>
Blanket Implementations§
source§impl<T> CheckedConversion for T
impl<T> CheckedConversion for T
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>,
§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
.