hotstuff_rs::pacemaker::implementation

Struct Pacemaker

source
pub(crate) struct Pacemaker<N: Network> {
    config: PacemakerConfiguration,
    state: PacemakerState,
    view_info: ViewInfo,
    sender: SenderHandle<N>,
    event_publisher: Option<Sender<Event>>,
}
Expand description

A single participant in the Pacemaker subprotocol.

§Usage

After creating an instance of the Pacemaker struct using new, the caller interacts with it by calling three methods:

After creating an instance of Pacemaker using new, the caller should interact with it by calling three methods:

  1. on_receive_msg: this method should be called whenever a PacemakerMessage is received satisfying the method’s preconditions.
  2. tick: this method should be called as often as is practical.
  3. query: whenever on_receive_msg or tick is called, the internal view counter of the Pacemaker may be updated. The caller should call query whenever it needs to see this counter.

Fields§

§config: PacemakerConfiguration§state: PacemakerState§view_info: ViewInfo§sender: SenderHandle<N>§event_publisher: Option<Sender<Event>>

Implementations§

source§

impl<N: Network> Pacemaker<N>

source

pub(crate) fn new( config: PacemakerConfiguration, sender: SenderHandle<N>, init_view: ViewNumber, init_validator_set_state: &ValidatorSetState, event_publisher: Option<Sender<Event>>, ) -> Result<Self, PacemakerError>

Create a new Pacemaker instance..

source

pub(crate) fn query(&self) -> &ViewInfo

Query the Pacemaker for its current ViewInfo.

source

pub(crate) fn tick<K: KVStore>( &mut self, block_tree: &BlockTreeSingleton<K>, ) -> Result<(), PacemakerError>

Cause the Pacemaker to check the current time (“clock tick”), possibly updating its internal state or causing it to send messages to other replicas.

source

pub(crate) fn on_receive_msg<K: KVStore>( &mut self, msg: PacemakerMessage, origin: &VerifyingKey, block_tree: &mut BlockTreeSingleton<K>, ) -> Result<(), PacemakerError>

Execute the required steps in the Pacemaker subprotocol upon receiving a PacemakerMessage from the replica identified by origin.

§Precondition

msg.view() must be greater than or equal to the current view.

source

fn on_receive_timeout_vote<K: KVStore>( &mut self, timeout_vote: TimeoutVote, origin: &VerifyingKey, block_tree: &mut BlockTreeSingleton<K>, ) -> Result<(), PacemakerError>

Execute the required steps in the Pacemaker subprotocol upon receiving a TimeoutVote message from the replica identified by origin.

§Precondition

timeout_vote.view >= self.query().view

source

fn on_receive_advance_view<K: KVStore>( &mut self, advance_view: AdvanceView, origin: &VerifyingKey, block_tree: &mut BlockTreeSingleton<K>, ) -> Result<(), PacemakerError>

Execute the required steps in the Pacemaker protocol upon receiving an AdvanceView message.

§Preconditions

advance_view.progress_certificate.view() >= self.query().view

source

fn update_view( &mut self, next_view: ViewNumber, validator_set_state: &ValidatorSetState, ) -> Result<(), PacemakerError>

Update the Pacemaker’s state in order to enter a specified next_view.

§Preconditions

This function should only be called if next_view is greater than the current view. Otherwise, an UpdateViewError will be returned.

source

fn extend_view(&mut self) -> Result<(), ExtendViewError>

Extend the timeout of the current view, which must be an Epoch-Change View.

§Errors

This function should only be called if the current view is an Epoch-Change View. Otherwise, an ExtendViewError will be returned.

Auto Trait Implementations§

§

impl<N> Freeze for Pacemaker<N>
where N: Freeze,

§

impl<N> RefUnwindSafe for Pacemaker<N>
where N: RefUnwindSafe,

§

impl<N> Send for Pacemaker<N>

§

impl<N> Sync for Pacemaker<N>
where N: Sync,

§

impl<N> Unpin for Pacemaker<N>
where N: Unpin,

§

impl<N> UnwindSafe for Pacemaker<N>
where N: UnwindSafe,

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<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

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

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

§

fn vzip(self) -> V