[−][src]Struct sn_farming::utils::RewardCounterSet
A util for calculating the median
of a vec of RewardCounters.
Implements Into
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]
expected_counters: usize,
counters: Vec<RewardCounter>
) -> Result<Self>
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
impl RefUnwindSafe for RewardCounterSet
impl Send for RewardCounterSet
impl Sync for RewardCounterSet
impl Unpin for RewardCounterSet
impl UnwindSafe for RewardCounterSet
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
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]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,