[][src]Struct sn_farming::utils::RewardCounterSet

pub struct RewardCounterSet { /* fields omitted */ }

A util for calculating the median of a vec of RewardCounters. Implements Into, since the semantics of this set is that it basically represents a single value, which we derive by taking the median of the set.

Implementations

impl RewardCounterSet[src]

The semantics of RewardCounterSet is that it basically represents a single value, as perceived by a fix set of different actors working as a group. We get the agreed value, by taking the median of the set. With at least 2/3 correctly working actors (e2e), we are ensured BFT.

pub fn new(
    expected_counters: usize,
    counters: Vec<RewardCounter>
) -> Result<Self>
[src]

The number of expected counters determines when we have an agreed value. Must be uneven. The vec can be empty or contain any number already.

pub fn len(&self) -> usize[src]

Returns the length of the set.

pub fn is_empty(&self) -> bool[src]

Returns whether the set is empty.

pub fn add(&mut self, counter: RewardCounter)[src]

Adds a counter to the set.

pub fn agreed_value(&self) -> Option<RewardCounter>[src]

Returns the agreed value between all, interpreted through the median value.

Auto Trait Implementations

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<T> From<T> for T[src]

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

impl<T> Same<T> for T

type Output = T

Should always be Self

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<V, T> VZip<V> for T where
    V: MultiLane<T>,