pub struct Block<T: NetworkEvent, P: PublicId> { /* private fields */ }
Expand description
A struct representing a collection of votes by peers for an Observation
.
Implementations§
Source§impl<T: NetworkEvent, P: PublicId> Block<T, P>
impl<T: NetworkEvent, P: PublicId> Block<T, P>
Sourcepub fn new_dkg_block(
(participants, dkg_result): (BTreeSet<P>, DkgResult),
) -> Self
pub fn new_dkg_block( (participants, dkg_result): (BTreeSet<P>, DkgResult), ) -> Self
Create a Block
with no signatures for a single DkgResult
Sourcepub fn payload(&self) -> &Observation<T, P>
pub fn payload(&self) -> &Observation<T, P>
Returns the payload of this block.
Sourcepub fn is_signed_by(&self, peer_id: &P) -> bool
pub fn is_signed_by(&self, peer_id: &P) -> bool
Is this block signed by the given peer?
Sourcepub fn add_vote(
&mut self,
peer_id: &P,
vote: &Vote<T, P>,
) -> Result<bool, Error>
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§
Source§impl<'de, T: NetworkEvent, P: PublicId> Deserialize<'de> for Block<T, P>
impl<'de, T: NetworkEvent, P: PublicId> Deserialize<'de> for Block<T, P>
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<T: Ord + NetworkEvent, P: Ord + PublicId> Ord for Block<T, P>
impl<T: Ord + NetworkEvent, P: Ord + PublicId> Ord for Block<T, P>
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl<T: PartialOrd + NetworkEvent, P: PartialOrd + PublicId> PartialOrd for Block<T, P>
impl<T: PartialOrd + NetworkEvent, P: PartialOrd + PublicId> PartialOrd for Block<T, P>
impl<T: Eq + NetworkEvent, P: Eq + PublicId> Eq for Block<T, P>
impl<T: NetworkEvent, P: PublicId> StructuralPartialEq for Block<T, P>
Auto Trait Implementations§
impl<T, P> Freeze for Block<T, P>
impl<T, P> RefUnwindSafe for Block<T, P>
impl<T, P> Send for Block<T, P>
impl<T, P> Sync for Block<T, P>
impl<T, P> Unpin for Block<T, P>
impl<T, P> UnwindSafe for Block<T, P>where
P: UnwindSafe + RefUnwindSafe,
T: UnwindSafe,
<P as PublicId>::Signature: RefUnwindSafe + UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more