Proposal

Struct Proposal 

Source
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>

Source

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.

Source

pub const fn batch_header(&self) -> &BatchHeader<N>

Returns the proposed batch header.

Source

pub const fn batch_id(&self) -> Field<N>

Returns the proposed batch ID.

Source

pub const fn round(&self) -> u64

Returns the round of the batch header.

Source

pub const fn timestamp(&self) -> i64

Returns the timestamp of the batch header.

Source

pub const fn transmissions( &self, ) -> &IndexMap<TransmissionID<N>, Transmission<N>>

Returns the transmissions.

Source

pub fn into_transmissions(self) -> IndexMap<TransmissionID<N>, Transmission<N>>

Returns the transmissions.

Source

pub fn signers(&self) -> HashSet<Address<N>>

Returns all the signers, including author and endorsers.

Source

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.

Source

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.

Source

pub fn contains_transmission( &self, transmission_id: impl Into<TransmissionID<N>>, ) -> bool

Returns true if the proposal contains the given transmission ID.

Source

pub fn get_transmission( &self, transmission_id: impl Into<TransmissionID<N>>, ) -> Option<&Transmission<N>>

Returns the transmission for the given transmission ID.

Source

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).

Source

pub fn to_certificate( &self, committee: &Committee<N>, ) -> Result<(BatchCertificate<N>, IndexMap<TransmissionID<N>, Transmission<N>>)>

Returns the batch certificate and transmissions.

Trait Implementations§

Source§

impl<N: Debug + Network> Debug for Proposal<N>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<N: Network> FromBytes for Proposal<N>

Source§

fn read_le<R: Read>(reader: R) -> IoResult<Self>

Reads Self from reader as little-endian bytes.
Source§

fn from_bytes_le(bytes: &[u8]) -> Result<Self, Error>
where Self: Sized,

Returns Self from a byte array in little-endian order.
Source§

impl<N: PartialEq + Network> PartialEq for Proposal<N>

Source§

fn eq(&self, other: &Proposal<N>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<N: Network> ToBytes for Proposal<N>

Source§

fn write_le<W: Write>(&self, writer: W) -> IoResult<()>

Writes self into writer as little-endian bytes.
Source§

fn to_bytes_le(&self) -> Result<Vec<u8>, Error>
where Self: Sized,

Returns self as a byte array in little-endian order.
Source§

impl<N: Eq + Network> Eq for Proposal<N>

Source§

impl<N: Network> StructuralPartialEq for Proposal<N>

Auto Trait Implementations§

§

impl<N> Freeze for Proposal<N>

§

impl<N> RefUnwindSafe for Proposal<N>

§

impl<N> Send for Proposal<N>

§

impl<N> Sync for Proposal<N>

§

impl<N> Unpin for Proposal<N>

§

impl<N> UnwindSafe for Proposal<N>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,