Struct parsec::Block [−][src]
pub struct Block<T: NetworkEvent, P: PublicId> { /* fields omitted */ }
A struct representing a collection of votes by peers for a network event of type T
.
Methods
impl<T: NetworkEvent, P: PublicId> Block<T, P>
[src]
impl<T: NetworkEvent, P: PublicId> Block<T, P>
pub fn new(payload: T, votes: &BTreeMap<P, Vote<T, P>>) -> Result<Self, Error>
[src]
pub fn new(payload: T, votes: &BTreeMap<P, Vote<T, P>>) -> Result<Self, Error>
Creates a Block
from payload
and votes
.
pub fn payload(&self) -> &T
[src]
pub fn payload(&self) -> &T
Returns the payload of this block.
pub fn proofs(&self) -> &BTreeSet<Proof<P>>
[src]
pub fn proofs(&self) -> &BTreeSet<Proof<P>>
Returns the proofs of this block.
pub fn add_vote(
&mut self,
peer_id: &P,
vote: &Vote<T, P>
) -> Result<bool, Error>
[src]
pub fn add_vote(
&mut self,
peer_id: &P,
vote: &Vote<T, P>
) -> Result<bool, Error>
Converts vote
to a Proof
and attempts to add it to the block. Returns an error if
vote
is invalid (i.e. signature check fails or the vote
is for a different network
event), Ok(true)
if the Proof
wasn't previously held in this Block
, or Ok(false)
if
it was previously held.
Trait Implementations
impl<T: Clone + NetworkEvent, P: Clone + PublicId> Clone for Block<T, P>
[src]
impl<T: Clone + NetworkEvent, P: Clone + PublicId> Clone for Block<T, P>
fn clone(&self) -> Block<T, P>
[src]
fn clone(&self) -> Block<T, P>
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl<T: PartialEq + NetworkEvent, P: PartialEq + PublicId> PartialEq for Block<T, P>
[src]
impl<T: PartialEq + NetworkEvent, P: PartialEq + PublicId> PartialEq for Block<T, P>
fn eq(&self, other: &Block<T, P>) -> bool
[src]
fn eq(&self, other: &Block<T, P>) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Block<T, P>) -> bool
[src]
fn ne(&self, other: &Block<T, P>) -> bool
This method tests for !=
.
impl<T: Eq + NetworkEvent, P: Eq + PublicId> Eq for Block<T, P>
[src]
impl<T: Eq + NetworkEvent, P: Eq + PublicId> Eq for Block<T, P>
impl<T: PartialOrd + NetworkEvent, P: PartialOrd + PublicId> PartialOrd for Block<T, P>
[src]
impl<T: PartialOrd + NetworkEvent, P: PartialOrd + PublicId> PartialOrd for Block<T, P>
fn partial_cmp(&self, other: &Block<T, P>) -> Option<Ordering>
[src]
fn partial_cmp(&self, other: &Block<T, P>) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, other: &Block<T, P>) -> bool
[src]
fn lt(&self, other: &Block<T, P>) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, other: &Block<T, P>) -> bool
[src]
fn le(&self, other: &Block<T, P>) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, other: &Block<T, P>) -> bool
[src]
fn gt(&self, other: &Block<T, P>) -> bool
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, other: &Block<T, P>) -> bool
[src]
fn ge(&self, other: &Block<T, P>) -> bool
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl<T: Ord + NetworkEvent, P: Ord + PublicId> Ord for Block<T, P>
[src]
impl<T: Ord + NetworkEvent, P: Ord + PublicId> Ord for Block<T, P>
fn cmp(&self, other: &Block<T, P>) -> Ordering
[src]
fn cmp(&self, other: &Block<T, P>) -> Ordering
This method returns an Ordering
between self
and other
. Read more
fn max(self, other: Self) -> Self
1.21.0[src]
fn max(self, other: Self) -> Self
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
1.21.0[src]
fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
impl<T: Debug + NetworkEvent, P: Debug + PublicId> Debug for Block<T, P>
[src]
impl<T: Debug + NetworkEvent, P: Debug + PublicId> Debug for Block<T, P>