Trait round_based::containers::MessageStore
source · [−]pub trait MessageStore {
type M;
type Err;
type Output;
fn push_msg(&mut self, msg: Msg<Self::M>) -> Result<(), Self::Err>;
fn contains_msg_from(&self, sender: u16) -> bool;
fn wants_more(&self) -> bool;
fn finish(self) -> Result<Self::Output, Self::Err>;
fn blame(&self) -> (u16, Vec<u16>);
}Expand description
Accumulates messages received from other parties
StateMachine implementations need to handle incoming messages: they need to store messages somewhere until sufficient messages received, incoming messages needs to be pre-validated (haven’t we received message from this party at this round? is it a p2p message, as we expected? and so on). MessageStore encapsulates all this boilerplate.
Required Associated Types
Required Methods
Pushes received message to store
Might result in error if pre-validation failed. However, it does not prevent MessageStore from accepting further messages.
fn contains_msg_from(&self, sender: u16) -> bool
fn contains_msg_from(&self, sender: u16) -> bool
Indicates if store contains message from this party
fn wants_more(&self) -> bool
fn wants_more(&self) -> bool
Indicates whether store needs more messages to receive
Returns resulting messages container
Returns error if store needs more messages (see wants_more).