hotstuff_rs::networking::receiving

Struct ProgressMessageStub

source
pub(crate) struct ProgressMessageStub {
    receiver: Receiver<(VerifyingKey, ProgressMessage)>,
    msg_buffer: ProgressMessageBuffer,
}
Expand description

A receiving end for ProgressMessages.

§View-aware buffering

ProgressMessageStub performs “view-aware buffering”. This means that it inspects incoming messages’ view numbers to decide whether to:

  1. Return it from recv for immediate processing.
  2. Place it in its buffer for future processing.
  3. Discard it.

ProgressMessageStub applies different view-aware policies depending on whether the incoming message is a HotStuff message, a Pacemaker message, or a BlockSyncTrigger message. These policies are detailed below:

§HotStuff messages

recv returns HotStuff messages for only the current view, and caches messages from future views for future processing. This helps prevent interruptions to progress when replicas’ views are mostly synchronized but they enter views at slightly different times.

§Pacemaker messages

recv returns Pacemaker messages for any view greater than or equal to the current view. It also caches all messages for views greater than the current view, for processing in the intended view in case immediate processing is not possible.

§BlockSyncTrigger messages

recv returns block sync trigger messages immediately without buffering.

§Buffer management

If ProgressMessageStub’s message buffer grows beyond the maximum capacity specified in new, some future-viewed messages might be removed from the buffer to make space for the new message. The logic for removing future-viewed messages removes highest-viewed messages first.

Fields§

§receiver: Receiver<(VerifyingKey, ProgressMessage)>§msg_buffer: ProgressMessageBuffer

Implementations§

source§

impl ProgressMessageStub

source

pub(crate) fn new( receiver: Receiver<(VerifyingKey, ProgressMessage)>, msg_buffer_capacity: BufferSize, ) -> ProgressMessageStub

Create a fresh ProgressMessageStub with a given receiver end and buffer capacity.

source

pub(crate) fn recv( &mut self, chain_id: ChainID, cur_view: ViewNumber, deadline: Instant, ) -> Result<(VerifyingKey, ProgressMessage), ProgressMessageReceiveError>

Receive a message matching the specified chain_id, and view >= current view (if any). Cache and/or return immediately, depending on the message type. Messages older than current view are dropped immediately. BlockSyncAdvertiseMessage messages are not associated with a view, and so they are returned immediately.

Auto Trait Implementations§

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