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

Message body

Error type

Resulting messages container holding received messages

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.

Indicates if store contains message from this party

Indicates whether store needs more messages to receive

Returns resulting messages container

Returns error if store needs more messages (see wants_more).

Retrieve uncooperative parties

Returns how many more messages we expected to receive and list of parties who didn’t send a message

Implementors