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:
- Return it from
recv
for immediate processing. - Place it in its buffer for future processing.
- 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
impl ProgressMessageStub
sourcepub(crate) fn new(
receiver: Receiver<(VerifyingKey, ProgressMessage)>,
msg_buffer_capacity: BufferSize,
) -> ProgressMessageStub
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.
sourcepub(crate) fn recv(
&mut self,
chain_id: ChainID,
cur_view: ViewNumber,
deadline: Instant,
) -> Result<(VerifyingKey, ProgressMessage), ProgressMessageReceiveError>
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.