[−][src]Struct core_cbc_casper::justification::LatestMessagesHonest
Set of latest honest messages
for each validator
. Works like LatestMessages
but ignores
equivocations.
Example
Using the VoteCount
type message type for brevity's sake.
use core_cbc_casper::justification::{Justification, LatestMessages, LatestMessagesHonest}; use core_cbc_casper::message::Message; use core_cbc_casper::VoteCount; use std::collections::HashSet; use std::iter::FromIterator; let mut justification = Justification::empty(); let message_0 = Message::new(0, justification.clone(), VoteCount { yes: 1, no: 0 }); justification.insert(message_0.clone()); assert_eq!( HashSet::<&Message<_>>::from_iter(LatestMessagesHonest::from_latest_messages( &LatestMessages::from(&justification), &HashSet::new(), ).iter()), HashSet::from_iter(vec![&message_0]), ); // message_1 will replace message_0 in the LatestMessagesHonest. let message_1 = Message::new(0, justification.clone(), VoteCount { yes: 2, no: 0 }); justification.insert(message_1.clone()); assert_eq!( HashSet::<&Message<_>>::from_iter(LatestMessagesHonest::from_latest_messages( &LatestMessages::from(&justification), &HashSet::new(), ).iter()), HashSet::from_iter(vec![&message_1]), ); // As the validator is no longer honest, his messages are ignored. let message_2 = Message::new(0, justification.clone(), VoteCount { yes: 3, no: 0 }); let message_3 = Message::new(0, justification.clone(), VoteCount { yes: 2, no: 1 }); justification.insert(message_2.clone()); justification.insert(message_3.clone()); assert_eq!( HashSet::<&Message<_>>::from_iter(LatestMessagesHonest::from_latest_messages( &LatestMessages::from(&justification), &HashSet::new(), ).iter()), HashSet::from_iter(vec![]), );
Methods
impl<E: Estimator> LatestMessagesHonest<E>
[src]
pub fn remove(&mut self, validator: &E::ValidatorName)
[src]
Removes the messages from a validator.
pub fn from_latest_messages(
latest_messages: &LatestMessages<E>,
equivocators: &HashSet<E::ValidatorName>
) -> Self
[src]
latest_messages: &LatestMessages<E>,
equivocators: &HashSet<E::ValidatorName>
) -> Self
Filters the latest messages to retrieve the latest honest messages and remove equivocators.
pub fn iter(&self) -> Iter<Message<E>>
[src]
pub fn len(&self) -> usize
[src]
pub fn is_empty(&self) -> bool
[src]
pub fn make_estimate<U: WeightUnit>(
&self,
validators_weights: &Weights<E::ValidatorName, U>
) -> Result<E, E::Error>
[src]
&self,
validators_weights: &Weights<E::ValidatorName, U>
) -> Result<E, E::Error>
Trait Implementations
impl<E: Clone + Estimator> Clone for LatestMessagesHonest<E>
[src]
fn clone(&self) -> LatestMessagesHonest<E>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<E: Estimator> From<LatestMessagesHonest<E>> for Justification<E>
[src]
fn from(lmh: LatestMessagesHonest<E>) -> Self
[src]
Auto Trait Implementations
impl<E> RefUnwindSafe for LatestMessagesHonest<E> where
E: RefUnwindSafe,
<E as Estimator>::ValidatorName: RefUnwindSafe,
E: RefUnwindSafe,
<E as Estimator>::ValidatorName: RefUnwindSafe,
impl<E> Send for LatestMessagesHonest<E> where
<E as Estimator>::ValidatorName: Send + Sync,
<E as Estimator>::ValidatorName: Send + Sync,
impl<E> Sync for LatestMessagesHonest<E> where
<E as Estimator>::ValidatorName: Send + Sync,
<E as Estimator>::ValidatorName: Send + Sync,
impl<E> Unpin for LatestMessagesHonest<E>
impl<E> UnwindSafe for LatestMessagesHonest<E> where
E: RefUnwindSafe,
<E as Estimator>::ValidatorName: RefUnwindSafe,
E: RefUnwindSafe,
<E as Estimator>::ValidatorName: RefUnwindSafe,
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> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
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>,