/// Handles a message received from `sender_id`.
///
/// This must be called with every message we receive from another node.
Handles a message received from `sender_id`.
This must be called with every message we receive from another node.
Handles a message received from ` sender_id ` . This must be called with every message we receive from another node .
pub fn handle_message(&mut self, sender_id: &N, msg: Message) -> Result<Step<N>> {
        let Message { epoch, content } = msg;
        if self.decision.is_some() || (epoch < self.epoch && content.can_expire()) {
            // Message is obsolete: We are already in a later epoch or terminated.
            Ok(Step::default())
        } else if epoch > self.epoch + self.max_future_epochs {
            Ok(Fault::new(sender_id.clone(), FaultKind::AgreementEpoch).into())
        } else if epoch > self.epoch {
            // Message is for a later epoch. We can't handle that yet.
            let epoch_state = self
                .incoming_queue
                .entry(epoch)
                .or_insert_with(BTreeMap::new);
            let received = epoch_state
                .entry(sender_id.clone())
                .or_insert_with(ReceivedMessages::new);
            Ok(received
                .insert(content)
                .map_or_else(Step::default, |fault| {
                    Fault::new(sender_id.clone(), fault).into()
                }))
        } else {
            self.handle_message_content(sender_id, content)
        }
    }
pub fn handle_message ( & mut self , sender_id : & N , msg : Message ) -> Result < Step < N > > { let Message { epoch , content } = msg ; if self . decision . is_some ( ) || ( epoch < self . epoch && content . can_expire ( ) ) { // Message is obsolete: We are already in a later epoch or terminated. Ok ( Step :: default ( ) ) } else if epoch > self . epoch + self . max_future_epochs { Ok ( Fault :: new ( sender_id . clone ( ) , FaultKind :: AgreementEpoch ) . into ( ) ) } else if epoch > self . epoch { // Message is for a later epoch. We can't handle that yet. let epoch_state = self . incoming_queue . entry ( epoch ) . or_insert_with ( BTreeMap :: new ) ; let received = epoch_state . entry ( sender_id . clone ( ) ) . or_insert_with ( ReceivedMessages :: new ) ; Ok ( received . insert ( content ) . map_or_else ( Step :: default , | fault | { Fault :: new ( sender_id . clone ( ) , fault ) . into ( ) } ) ) } else { self . handle_message_content ( sender_id , content ) } }
Handles a message received from `sender_id`.
Handles a message received from ` sender_id ` .
&mut self
sender_id
&N
msg
Message