pub struct Proposal<N: Network> { /* private fields */ }Expand description
A pending proposal by a validator.
When a validator creates and broadcasts a proposal, it collects endorsing signatures from other validators. When the validator has enough endorsements, it turns the proposal into a certificate. This struct holds the information about the pending proposal, in the proposing validator’s state, between the creation of the proposal and its turning into a certificate.
Invariant: batch_header.transmission_ids() contains the same elements as transmissions.keys().
Proposal::new and Proposal::read_le establish the invariant, by checking the condition;
none of the other functions modifies the batch header or the transmissions.
Implementations§
Source§impl<N: Network> Proposal<N>
impl<N: Network> Proposal<N>
Sourcepub fn new(
committee: Committee<N>,
batch_header: BatchHeader<N>,
transmissions: IndexMap<TransmissionID<N>, Transmission<N>>,
) -> Result<Self>
pub fn new( committee: Committee<N>, batch_header: BatchHeader<N>, transmissions: IndexMap<TransmissionID<N>, Transmission<N>>, ) -> Result<Self>
Initializes a new instance of the proposal.
The committee input is the active (i.e. lookback) committee for the batch round.
A crucial protocol safety check made in this constructor is that the proposal author (the current validator),
is a member of that committee, because only members of the committee can propose batches.
Sourcepub const fn batch_header(&self) -> &BatchHeader<N>
pub const fn batch_header(&self) -> &BatchHeader<N>
Returns the proposed batch header.
Sourcepub const fn transmissions(
&self,
) -> &IndexMap<TransmissionID<N>, Transmission<N>>
pub const fn transmissions( &self, ) -> &IndexMap<TransmissionID<N>, Transmission<N>>
Returns the transmissions.
Sourcepub fn into_transmissions(self) -> IndexMap<TransmissionID<N>, Transmission<N>>
pub fn into_transmissions(self) -> IndexMap<TransmissionID<N>, Transmission<N>>
Returns the transmissions.
Sourcepub fn signers(&self) -> HashSet<Address<N>>
pub fn signers(&self) -> HashSet<Address<N>>
Returns all the signers, including author and endorsers.
Sourcepub fn nonsigners(&self, committee: &Committee<N>) -> HashSet<Address<N>>
pub fn nonsigners(&self, committee: &Committee<N>) -> HashSet<Address<N>>
Returns the non-signers, i.e. the committee members that have not signed the proposal.
Sourcepub fn is_quorum_threshold_reached(&self, committee: &Committee<N>) -> bool
pub fn is_quorum_threshold_reached(&self, committee: &Committee<N>) -> bool
Returns true if the signers of the batch (author and endorsers)
have reached the quorum threshold for the committee.
Sourcepub fn contains_transmission(
&self,
transmission_id: impl Into<TransmissionID<N>>,
) -> bool
pub fn contains_transmission( &self, transmission_id: impl Into<TransmissionID<N>>, ) -> bool
Returns true if the proposal contains the given transmission ID.
Sourcepub fn get_transmission(
&self,
transmission_id: impl Into<TransmissionID<N>>,
) -> Option<&Transmission<N>>
pub fn get_transmission( &self, transmission_id: impl Into<TransmissionID<N>>, ) -> Option<&Transmission<N>>
Returns the transmission for the given transmission ID.
Sourcepub fn add_signature(
&mut self,
signer: Address<N>,
signature: Signature<N>,
committee: &Committee<N>,
) -> Result<()>
pub fn add_signature( &mut self, signer: Address<N>, signature: Signature<N>, committee: &Committee<N>, ) -> Result<()>
Adds an endorsing signature to the proposal, if the signature is valid and the signer is a committee member that has not already signed the proposal (this implicitly checks that the signature is not from the author).
Sourcepub fn to_certificate(
&self,
committee: &Committee<N>,
) -> Result<(BatchCertificate<N>, IndexMap<TransmissionID<N>, Transmission<N>>)>
pub fn to_certificate( &self, committee: &Committee<N>, ) -> Result<(BatchCertificate<N>, IndexMap<TransmissionID<N>, Transmission<N>>)>
Returns the batch certificate and transmissions.
Trait Implementations§
impl<N: Eq + Network> Eq for Proposal<N>
impl<N: Network> StructuralPartialEq for Proposal<N>
Auto Trait Implementations§
impl<N> Freeze for Proposal<N>where
<N as Environment>::Field: Freeze,
<N as Environment>::Projective: Freeze,
<N as Environment>::Scalar: Freeze,
impl<N> RefUnwindSafe for Proposal<N>where
<N as Environment>::Field: RefUnwindSafe,
<N as Environment>::Projective: RefUnwindSafe,
<N as Environment>::Scalar: RefUnwindSafe,
<N as Network>::TransmissionChecksum: RefUnwindSafe,
<N as Network>::TransactionID: RefUnwindSafe,
N: RefUnwindSafe,
<N as Network>::BlockHash: RefUnwindSafe,
<N as Network>::StateRoot: RefUnwindSafe,
<N as Network>::TransitionID: RefUnwindSafe,
<<N as Environment>::PairingCurve as PairingEngine>::G1Affine: RefUnwindSafe,
impl<N> Send for Proposal<N>
impl<N> Sync for Proposal<N>
impl<N> Unpin for Proposal<N>where
<N as Environment>::Field: Unpin,
<N as Environment>::Projective: Unpin,
<N as Environment>::Scalar: Unpin,
<N as Network>::TransmissionChecksum: Unpin,
<N as Network>::TransactionID: Unpin,
N: Unpin,
<N as Network>::BlockHash: Unpin,
<N as Network>::StateRoot: Unpin,
<N as Network>::TransitionID: Unpin,
<<N as Environment>::PairingCurve as PairingEngine>::G1Affine: Unpin,
impl<N> UnwindSafe for Proposal<N>where
<N as Environment>::Field: UnwindSafe,
<N as Environment>::Projective: UnwindSafe,
<N as Environment>::Scalar: UnwindSafe,
<N as Network>::TransmissionChecksum: UnwindSafe,
<N as Network>::TransactionID: UnwindSafe,
N: UnwindSafe,
<N as Network>::BlockHash: UnwindSafe,
<N as Network>::StateRoot: UnwindSafe,
<N as Network>::TransitionID: UnwindSafe,
<<N as Environment>::PairingCurve as PairingEngine>::G1Affine: UnwindSafe + RefUnwindSafe,
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
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more