[−][src]Struct core_cbc_casper::justification::Justification
This struct holds the set of the Message
that justify
the current message. It works like a Vec
.
Example
Using the VoteCount
type message type for brevity's sake.
use core_cbc_casper::justification::Justification; use core_cbc_casper::message::Message; use core_cbc_casper::VoteCount; let message = VoteCount::create_vote_message(0, true); let mut justification = Justification::empty(); justification.insert(message.clone()); assert_eq!( *justification.iter().next().unwrap().estimate(), VoteCount { yes: 1, no: 0 }, );
Methods
impl<E: Estimator> Justification<E>
[src]
pub fn empty() -> Self
[src]
Creates an empty justification.
pub fn from_messages<U: WeightUnit>(
messages: Vec<Message<E>>,
state: &mut State<E, U>
) -> Self
[src]
messages: Vec<Message<E>>,
state: &mut State<E, U>
) -> Self
Creates and returns a new justification from a vector of
Message
and mutates the given validator::State
with the updated state.
pub fn iter(&self) -> Iter<Message<E>>
[src]
pub fn par_iter(&self) -> Iter<Message<E>>
[src]
pub fn contains(&self, message: &Message<E>) -> bool
[src]
pub fn len(&self) -> usize
[src]
pub fn is_empty(&self) -> bool
[src]
pub fn insert(&mut self, message: Message<E>) -> bool
[src]
This function checks if the message
is already contained into the underlying Vec
. If it
is, it does nothing and returns false. Else, it will push the message in the Vec
and
returns true.
pub fn make_estimate<U: WeightUnit>(
&self,
equivocators: &HashSet<E::ValidatorName>,
validators_weights: &Weights<E::ValidatorName, U>
) -> Result<E, E::Error>
[src]
&self,
equivocators: &HashSet<E::ValidatorName>,
validators_weights: &Weights<E::ValidatorName, U>
) -> Result<E, E::Error>
Runs the estimator
on the justification given the set of equivocators and validators' weights
.
pub fn faulty_inserts<'a, U: WeightUnit>(
&mut self,
messages: &HashSet<&'a Message<E>>,
state: &mut State<E, U>
) -> HashSet<&'a Message<E>>
[src]
&mut self,
messages: &HashSet<&'a Message<E>>,
state: &mut State<E, U>
) -> HashSet<&'a Message<E>>
Inserts messages
to the justification, accepting up to the threshold faults by weight.
In ordering to insert as much messages as possible, the input messages are sorted
ascendingly by their validators' weight
.
Returns a HashSet
of messages that got successfully included in the justification.
pub fn faulty_insert<U: WeightUnit>(
&mut self,
message: &Message<E>,
state: &mut State<E, U>
) -> bool
[src]
&mut self,
message: &Message<E>,
state: &mut State<E, U>
) -> bool
This function makes no assumption on how to treat the equivocator. It adds the message to the justification only if it will not cross the fault tolerance threshold.
pub fn faulty_insert_with_slash<'a, U: WeightUnit>(
&mut self,
message: &Message<E>,
state: &'a mut State<E, U>
) -> Result<bool, Error<'a, HashMap<E::ValidatorName, U>>>
[src]
&mut self,
message: &Message<E>,
state: &'a mut State<E, U>
) -> Result<bool, Error<'a, HashMap<E::ValidatorName, U>>>
This function sets the weight of an equivocator to zero right away (returned in
validator::State
) and add his message to the state, since his weight is null and doesn't
count to the state fault weight anymore.
Trait Implementations
impl<E: Clone + Estimator> Clone for Justification<E>
[src]
fn clone(&self) -> Justification<E>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<E: Estimator> Debug for Justification<E>
[src]
impl<E: Eq + Estimator> Eq for Justification<E>
[src]
impl<'_, E: Estimator> From<&'_ Justification<E>> for LatestMessages<E>
[src]
fn from(justification: &Justification<E>) -> Self
[src]
Extracts the latest messages of each validator from a justification
.
impl<E: Estimator> From<LatestMessagesHonest<E>> for Justification<E>
[src]
fn from(lmh: LatestMessagesHonest<E>) -> Self
[src]
impl<E: Hash + Estimator> Hash for Justification<E>
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl<E: PartialEq + Estimator> PartialEq<Justification<E>> for Justification<E>
[src]
fn eq(&self, other: &Justification<E>) -> bool
[src]
fn ne(&self, other: &Justification<E>) -> bool
[src]
impl<E: Estimator> StructuralEq for Justification<E>
[src]
impl<E: Estimator> StructuralPartialEq for Justification<E>
[src]
Auto Trait Implementations
impl<E> RefUnwindSafe for Justification<E> where
E: RefUnwindSafe,
<E as Estimator>::ValidatorName: RefUnwindSafe,
E: RefUnwindSafe,
<E as Estimator>::ValidatorName: RefUnwindSafe,
impl<E> Send for Justification<E> where
<E as Estimator>::ValidatorName: Send + Sync,
<E as Estimator>::ValidatorName: Send + Sync,
impl<E> Sync for Justification<E> where
<E as Estimator>::ValidatorName: Send + Sync,
<E as Estimator>::ValidatorName: Send + Sync,
impl<E> Unpin for Justification<E>
impl<E> UnwindSafe for Justification<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>,