pub struct VoterSet<Id: Eq + Ord> { /* private fields */ }
Expand description

A (non-empty) set of voters and associated weights.

A VoterSet identifies all voters that are permitted to vote in a round of the protocol and their associated weights. A VoterSet is furthermore equipped with a total order, given by the ordering of the voter’s IDs.

Implementations

Create a voter set from a weight distribution produced by the given iterator.

If the distribution contains multiple weights for the same voter ID, they are understood to be partial weights and are accumulated. As a result, the order in which the iterator produces the weights is irrelevant.

Returns None if the iterator does not yield a valid voter set, which is the case if it either produced no non-zero weights or, i.e. the voter set would be empty, or if the total voter weight exceeds u64::MAX.

Get the voter info for the voter with the given ID, if any.

Get the size of the set.

Whether the set contains a voter with the given ID.

Get the nth voter in the set, modulo the size of the set, as per the associated total order.

Get the nth voter in the set, if any.

Returns None if n >= len.

Get the threshold vote weight required for supermajority w.r.t. this set of voters.

Get the total weight of all voters.

Get an iterator over the voters in the set, as given by the associated total order.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.