fn handle_append_entries(&mut self, m: Message) {
        if m.get_index() < self.raft_log.committed {
            self.send(Message { to: m.from, field_type: MsgAppResp, index: self.raft_log.committed, ..Default::default() });
            return;
        }

        if let Some(m_last_index) = self.raft_log.maybe_append(
            m.get_index(),
            m.get_logTerm(),
            m.get_commit(),
            m.get_entries(),
        ) {
            self.send(Message { to: m.from, field_type: MsgAppResp, index: m_last_index, ..Default::default() });
        } else {
            debug!(
                "{:x} [logterm: {}, index: {}] rejected MsgApp [logterm: {}, index: {}] from {:#x}",
                self.id,
                self.raft_log.zero_term_on_err_compacted(m.get_index()),
                m.get_index(),
                m.get_logTerm(),
                m.get_index(),
                m.get_from(),
            );
            self.send(Message { to: m.from, field_type: MsgAppResp, index: m.index, reject: true, rejectHint: self.raft_log.last_index(), ..Default::default() });
        }
    }
// handle_append_entries handle append entries RPC request
handle_append_entries handle append entries RPC request
handle_append_entries handle append entries RPC request
fn handle_append_entries(&mut self, m: Message) {
        if m.get_index() < self.raft_log.committed {
            self.send(Message { to: m.from, field_type: MsgAppResp, index: self.raft_log.committed, ..Default::default() });
            return;
        }
        if let Some(m_last_index) = self.raft_log.maybe_append(
            m.get_index(),
            m.get_logTerm(),
            m.get_commit(),
            m.get_entries(),
        ) {
            self.send(Message { to: m.from, field_type: MsgAppResp, index: m_last_index, ..Default::default() });
        } else {
            debug!(
                "{:x} [logterm: {}, index: {}] rejected MsgApp [logterm: {}, index: {}] from {:#x}",
                self.id,
                self.raft_log.zero_term_on_err_compacted(m.get_index()),
                m.get_index(),
                m.get_logTerm(),
                m.get_index(),
                m.get_from(),
            );
            self.send(Message { to: m.from, field_type: MsgAppResp, index: m.index, reject: true, rejectHint: self.raft_log.last_index(), ..Default::default() });
        }
    }
fn handle_append_entries ( & mut self , m : Message ) { if m . get_index ( ) < self . raft_log . committed { self . send ( Message { to : m . from , field_type : MsgAppResp , index : self . raft_log . committed , .. Default :: default ( ) } ) ; return ; } if let Some ( m_last_index ) = self . raft_log . maybe_append ( m . get_index ( ) , m . get_logTerm ( ) , m . get_commit ( ) , m . get_entries ( ) , ) { self . send ( Message { to : m . from , field_type : MsgAppResp , index : m_last_index , .. Default :: default ( ) } ) ; } else { debug ! ( " " self id self raft_log zero_term_on_err_compacted ( m get_index ( ) ) m get_index ( ) m get_logTerm ( ) m get_index ( ) m get_from ( ) ) ; self . send ( Message { to : m . from , field_type : MsgAppResp , index : m . index , reject : true , rejectHint : self . raft_log . last_index ( ) , .. Default :: default ( ) } ) ; } }
handle_append_entries handle append entries RPC request
handle_append_entries handle append entries RPC request
&mut self
m
Message