Skip to main content

ConsensusState

Struct ConsensusState 

Source
pub struct ConsensusState<Ctx>
where Ctx: Context,
{ pub ctx: Ctx, pub params: Params<Ctx>, pub driver: Driver<Ctx>, pub input_queue: BoundedQueue<<Ctx as Context>::Height, Input<Ctx>>, pub full_proposal_keeper: FullProposalKeeper<Ctx>, pub last_signed_prevote: Option<SignedMessage<Ctx, <Ctx as Context>::Vote>>, pub last_signed_precommit: Option<SignedMessage<Ctx, <Ctx as Context>::Vote>>, pub target_time: Option<Duration>, pub height_start_time: Option<Instant>, pub finalization_period: bool, }
Expand description

The state maintained by consensus for processing a Input.

Fields§

§ctx: Ctx

The context for the consensus state machine

§params: Params<Ctx>

The consensus parameters

§driver: Driver<Ctx>

Driver for the per-round consensus state machine

§input_queue: BoundedQueue<<Ctx as Context>::Height, Input<Ctx>>

A queue of inputs that were received before the driver started.

§full_proposal_keeper: FullProposalKeeper<Ctx>

The proposals to decide on.

§last_signed_prevote: Option<SignedMessage<Ctx, <Ctx as Context>::Vote>>

Last prevote broadcasted by this node

§last_signed_precommit: Option<SignedMessage<Ctx, <Ctx as Context>::Vote>>

Last precommit broadcasted by this node

§target_time: Option<Duration>

Target time for the current height

§height_start_time: Option<Instant>

Start time of the current height

§finalization_period: bool

Whether we are in the finalization period.

The finalization period is entered in decide, cleared in finalize_height, and only valid during the commit step.

It allows collecting additional precommits for the decided value after the decision is made in decide, which can be included in the commit certificate.

Implementations§

Source§

impl<Ctx> State<Ctx>
where Ctx: Context,

Source

pub fn new( ctx: Ctx, height: <Ctx as Context>::Height, validator_set: <Ctx as Context>::ValidatorSet, params: Params<Ctx>, queue_capacity: usize, ) -> State<Ctx>

Source

pub fn height(&self) -> <Ctx as Context>::Height

Source

pub fn round(&self) -> Round

Source

pub fn address(&self) -> &<Ctx as Context>::Address

Source

pub fn validator_set(&self) -> &<Ctx as Context>::ValidatorSet

Source

pub fn get_proposer( &self, height: <Ctx as Context>::Height, round: Round, ) -> &<Ctx as Context>::Address

Source

pub fn set_last_vote( &mut self, vote: SignedMessage<Ctx, <Ctx as Context>::Vote>, )

Source

pub fn restore_precommits( &self, height: <Ctx as Context>::Height, round: Round, value: &<Ctx as Context>::Value, ) -> Vec<SignedMessage<Ctx, <Ctx as Context>::Vote>>

Source

pub fn polka_certificate( &self, round: Round, value_id: &<<Ctx as Context>::Value as Value>::Id, ) -> Option<&PolkaCertificate<Ctx>>

Get the polka certificate at the current height for the specified round and value, if it exists

Source

pub fn full_proposal_at_round_and_value( &self, height: &<Ctx as Context>::Height, round: Round, value: &<Ctx as Context>::Value, ) -> Option<&FullProposal<Ctx>>

Source

pub fn full_proposal_at_round_and_proposer( &self, height: &<Ctx as Context>::Height, round: Round, address: &<Ctx as Context>::Address, ) -> Option<&FullProposal<Ctx>>

Source

pub fn get_proposed_value_by_id( &self, height: <Ctx as Context>::Height, round: Round, value_id: &<<Ctx as Context>::Value as Value>::Id, ) -> Option<ProposedValue<Ctx>>

Get a proposed value by its ID at the specified height and round.

Source

pub fn proposals_for_value( &self, proposed_value: &ProposedValue<Ctx>, ) -> Vec<SignedMessage<Ctx, <Ctx as Context>::Proposal>>

Source

pub fn store_proposal( &mut self, new_proposal: SignedMessage<Ctx, <Ctx as Context>::Proposal>, )

Source

pub fn store_value(&mut self, new_value: &ProposedValue<Ctx>) -> Validity

Store the proposed value and return its validity, which may be now be different from the one provided.

Source

pub fn reset_and_start_height( &mut self, height: <Ctx as Context>::Height, validator_set: <Ctx as Context>::ValidatorSet, target_time: Option<Duration>, )

Source

pub fn decided_value(&self) -> Option<(Round, <Ctx as Context>::Value)>

Return the round and value id of the decided value.

Source

pub fn buffer_input( &mut self, height: <Ctx as Context>::Height, input: Input<Ctx>, _metrics: &Metrics, )

Queue an input for later processing, only keep inputs for the highest height seen so far.

Source

pub fn take_pending_inputs(&mut self, _metrics: &Metrics) -> Vec<Input<Ctx>>
where Ctx: Context,

Take all inputs that are pending for the specified height and remove from the input queue.

Source

pub fn print_state(&self)

Source

pub fn is_active_validator(&self) -> bool

Check if this node is an active validator.

Returns true only if:

  • Consensus is enabled in the configuration, AND
  • This node is present in the current validator set
Source

pub fn round_certificate(&self) -> Option<&EnterRoundCertificate<Ctx>>

Auto Trait Implementations§

§

impl<Ctx> Freeze for State<Ctx>
where Ctx: Freeze, <Ctx as Context>::Address: Freeze, <Ctx as Context>::ValidatorSet: Freeze, <Ctx as Context>::Height: Freeze, <Ctx as Context>::Vote: Freeze, <<Ctx as Context>::SigningScheme as SigningScheme>::Signature: Freeze, <Ctx as Context>::Value: Freeze,

§

impl<Ctx> RefUnwindSafe for State<Ctx>

§

impl<Ctx> Send for State<Ctx>

§

impl<Ctx> Sync for State<Ctx>

§

impl<Ctx> Unpin for State<Ctx>
where Ctx: Unpin, <Ctx as Context>::Address: Unpin, <Ctx as Context>::ValidatorSet: Unpin, <Ctx as Context>::Height: Unpin, <Ctx as Context>::Vote: Unpin, <<Ctx as Context>::SigningScheme as SigningScheme>::Signature: Unpin, <Ctx as Context>::Value: Unpin, <<Ctx as Context>::Value as Value>::Id: Unpin, <Ctx as Context>::Proposal: Unpin,

§

impl<Ctx> UnsafeUnpin for State<Ctx>

§

impl<Ctx> UnwindSafe for State<Ctx>

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<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

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<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> Message for T
where T: Any + Send + 'static,

Source§

fn from_boxed(m: BoxedMessage) -> Result<Self, BoxedDowncastErr>

Convert a BoxedMessage to this concrete type
Source§

fn box_message(self, pid: &ActorId) -> Result<BoxedMessage, BoxedDowncastErr>

Convert this message to a BoxedMessage
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> 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> State for T
where T: Any + Send + 'static,