fn commit_noop_entry(raft: &mut Raft<SafeMemStorage>) {
        assert_eq!(
            raft.state,
            StateType::Leader,
            "it should only be used when it is the leader"
        );
        raft.bcast_append();

        // simulate the response of msgApp
        let msgs = read_message(raft);
        for m in msgs {
            assert!(
                m.field_type == MsgApp
                    && m.entries.len() == 1
                    && m.entries.first().unwrap().Data.is_empty(),
                "not a message to append noop empty"
            );
            raft.step(accept_and_reply(m)).unwrap();
        }

        // ignore future messages to refresh followers' commit index
        read_message(raft);
        let unstable_entries = raft
            .raft_log
            .unstable_entries()
            .iter()
            .map(|entry| entry.clone())
            .collect::<Vec<_>>();
        raft.raft_log.storage.wl().append(unstable_entries).unwrap();
        raft.raft_log.applied_to(raft.raft_log.committed);
        raft.raft_log
            .stable_to(raft.raft_log.last_index(), raft.raft_log.last_term());
    }
// NOTE: the log has committed and applied
the log has committed and applied
the log has committed and applied
fn commit_noop_entry(raft: &mut Raft<SafeMemStorage>) {
        assert_eq!(
            raft.state,
            StateType::Leader,
            "it should only be used when it is the leader"
        );
        raft.bcast_append();
        // simulate the response of msgApp
        let msgs = read_message(raft);
        for m in msgs {
            assert!(
                m.field_type == MsgApp
                    && m.entries.len() == 1
                    && m.entries.first().unwrap().Data.is_empty(),
                "not a message to append noop empty"
            );
            raft.step(accept_and_reply(m)).unwrap();
        }
        // ignore future messages to refresh followers' commit index
        read_message(raft);
        let unstable_entries = raft
            .raft_log
            .unstable_entries()
            .iter()
            .map(|entry| entry.clone())
            .collect::<Vec<_>>();
        raft.raft_log.storage.wl().append(unstable_entries).unwrap();
        raft.raft_log.applied_to(raft.raft_log.committed);
        raft.raft_log
            .stable_to(raft.raft_log.last_index(), raft.raft_log.last_term());
    }
fn commit_noop_entry ( raft : & mut Raft < SafeMemStorage > ) { assert_eq ! ( raft state StateType Leader " " ) ; raft . bcast_append ( ) ; // simulate the response of msgApp let msgs = read_message ( raft ) ; for m in msgs { assert ! ( m field_type MsgApp m entries len ( ) 1 m entries first ( ) unwrap ( ) Data is_empty ( ) " " ) ; raft . step ( accept_and_reply ( m ) ) . unwrap ( ) ; } // ignore future messages to refresh followers' commit index read_message ( raft ) ; let unstable_entries = raft . raft_log . unstable_entries ( ) . iter ( ) . map ( | entry | entry . clone ( ) ) . collect :: < Vec < _ > > ( ) ; raft . raft_log . storage . wl ( ) . append ( unstable_entries ) . unwrap ( ) ; raft . raft_log . applied_to ( raft . raft_log . committed ) ; raft . raft_log . stable_to ( raft . raft_log . last_index ( ) , raft . raft_log . last_term ( ) ) ; }
NOTE: the log has committed and applied
NOTE : the log has committed and applied
raft
&mut Raft<SafeMemStorage>