fn handle_snapshot(&mut self, m: Message) {
        let (sindex, sterm) = (
            m.get_snapshot().get_metadata().get_index(),
            m.get_snapshot().get_metadata().get_term(),
        );
        if self.restore(m.get_snapshot()) {
            info!(
                "{:#x} [commit: {}] restored snapshot [index: {}, term: {}]",
                self.id, self.raft_log.committed, sindex, sterm
            );
            let mut msg = Message::new();
            msg.set_to(m.get_from());
            msg.set_field_type(MsgAppResp);
            msg.set_index(self.raft_log.last_index());
            self.send(msg);
        } else {
            info!(
                "{:#x} [commit: {}] ignored snapshot [index: {}, term: {}]",
                self.id, self.raft_log.committed, sindex, sterm,
            );
            let mut msg = Message::new();
            msg.set_to(m.get_from());
            msg.set_field_type(MsgAppResp);
            msg.set_index(self.raft_log.committed);
            self.send(msg);
        }
    }
// handles Snapshot RPC request, only invoked by Follower or Candidate
handles Snapshot RPC request, only invoked by Follower or Candidate
handles Snapshot RPC request only invoked by Follower or Candidate
fn handle_snapshot(&mut self, m: Message) {
        let (sindex, sterm) = (
            m.get_snapshot().get_metadata().get_index(),
            m.get_snapshot().get_metadata().get_term(),
        );
        if self.restore(m.get_snapshot()) {
            info!(
                "{:#x} [commit: {}] restored snapshot [index: {}, term: {}]",
                self.id, self.raft_log.committed, sindex, sterm
            );
            let mut msg = Message::new();
            msg.set_to(m.get_from());
            msg.set_field_type(MsgAppResp);
            msg.set_index(self.raft_log.last_index());
            self.send(msg);
        } else {
            info!(
                "{:#x} [commit: {}] ignored snapshot [index: {}, term: {}]",
                self.id, self.raft_log.committed, sindex, sterm,
            );
            let mut msg = Message::new();
            msg.set_to(m.get_from());
            msg.set_field_type(MsgAppResp);
            msg.set_index(self.raft_log.committed);
            self.send(msg);
        }
    }
fn handle_snapshot ( & mut self , m : Message ) { let ( sindex , sterm ) = ( m . get_snapshot ( ) . get_metadata ( ) . get_index ( ) , m . get_snapshot ( ) . get_metadata ( ) . get_term ( ) , ) ; if self . restore ( m . get_snapshot ( ) ) { info ! ( " " self id self raft_log committed sindex sterm ) ; let mut msg = Message :: new ( ) ; msg . set_to ( m . get_from ( ) ) ; msg . set_field_type ( MsgAppResp ) ; msg . set_index ( self . raft_log . last_index ( ) ) ; self . send ( msg ) ; } else { info ! ( " " self id self raft_log committed sindex sterm ) ; let mut msg = Message :: new ( ) ; msg . set_to ( m . get_from ( ) ) ; msg . set_field_type ( MsgAppResp ) ; msg . set_index ( self . raft_log . committed ) ; self . send ( msg ) ; } }
handles Snapshot RPC request, only invoked by Follower or Candidate
handles Snapshot RPC request only invoked by Follower or Candidate
&mut self
m
Message