fn send(&mut self, mut m: Message) {
        if m.from == NONE {
            m.from = self.id;
            info!("sent")
        }
        let msg_type = m.field_type;
        if msg_type == MsgVote
            || msg_type == MsgVoteResp
            || msg_type == MsgPreVote
            || msg_type == MsgPreVoteResp
        {
            // All {pre-, }campaign messages need to have the term set when
            // sending.
            // - MsgVote: m.Term is the term the node is campaigning for,
            //   non-zero as we increment the term when campaigning.
            // - MsgVoteResp: m.Term is the new r.Term if the MsgVote was
            //   granted, non-zero for the same reason MsgVote is
            // - MsgPreVote: m.Term is the term the node will campaign,
            //   non-zero as we use m.Term to indicate the next term we'll be
            //   campaigning fro
            // - MsgPreVoteResp: m.Term is the term received in th original
            //   MsgPreVote if the pre-vote was granted, non-zero for the
            //   same reasons MsgPreVote is
            assert_ne!(
                m.term, 0,
                "term should be set when sending {:?}",
                m.field_type,
            );
        } else {
            if m.term != 0 {
                panic!(
                    "term should not be set when sending {:?} (was {})",
                    m.field_type, m.term
                );
            }
            // do not attach term to MsgProp, MsgReadIndex
            // proposals are a way to forward to the leader and
            // should be treated as local message.
            // MsgReadIndex is also forwarded to leader.
            if m.field_type != MsgProp && m.field_type != MsgReadIndex {
                m.term = self.term;
            }
        }

        self.msgs.push(m);
    }
// persists state to stable storage and then sends to its mailbox.
persists state to stable storage and then sends to its mailbox.
persists state to stable storage and then sends to its mailbox .
fn send(&mut self, mut m: Message) {
        if m.from == NONE {
            m.from = self.id;
            info!("sent")
        }
        let msg_type = m.field_type;
        if msg_type == MsgVote
            || msg_type == MsgVoteResp
            || msg_type == MsgPreVote
            || msg_type == MsgPreVoteResp
        {
            // All {pre-, }campaign messages need to have the term set when
            // sending.
            // - MsgVote: m.Term is the term the node is campaigning for,
            //   non-zero as we increment the term when campaigning.
            // - MsgVoteResp: m.Term is the new r.Term if the MsgVote was
            //   granted, non-zero for the same reason MsgVote is
            // - MsgPreVote: m.Term is the term the node will campaign,
            //   non-zero as we use m.Term to indicate the next term we'll be
            //   campaigning fro
            // - MsgPreVoteResp: m.Term is the term received in th original
            //   MsgPreVote if the pre-vote was granted, non-zero for the
            //   same reasons MsgPreVote is
            assert_ne!(
                m.term, 0,
                "term should be set when sending {:?}",
                m.field_type,
            );
        } else {
            if m.term != 0 {
                panic!(
                    "term should not be set when sending {:?} (was {})",
                    m.field_type, m.term
                );
            }
            // do not attach term to MsgProp, MsgReadIndex
            // proposals are a way to forward to the leader and
            // should be treated as local message.
            // MsgReadIndex is also forwarded to leader.
            if m.field_type != MsgProp && m.field_type != MsgReadIndex {
                m.term = self.term;
            }
        }
        self.msgs.push(m);
    }
fn send ( & mut self , mut m : Message ) { if m . from == NONE { m . from = self . id ; info ! ( " " ) } let msg_type = m . field_type ; if msg_type == MsgVote || msg_type == MsgVoteResp || msg_type == MsgPreVote || msg_type == MsgPreVoteResp { // All {pre-, }campaign messages need to have the term set when // sending. // - MsgVote: m.Term is the term the node is campaigning for, //   non-zero as we increment the term when campaigning. // - MsgVoteResp: m.Term is the new r.Term if the MsgVote was //   granted, non-zero for the same reason MsgVote is // - MsgPreVote: m.Term is the term the node will campaign, //   non-zero as we use m.Term to indicate the next term we'll be //   campaigning fro // - MsgPreVoteResp: m.Term is the term received in th original //   MsgPreVote if the pre-vote was granted, non-zero for the //   same reasons MsgPreVote is assert_ne ! ( m term 0 " " m field_type ) ; } else { if m . term != 0 { panic ! ( " " m field_type m term ) ; } // do not attach term to MsgProp, MsgReadIndex // proposals are a way to forward to the leader and // should be treated as local message. // MsgReadIndex is also forwarded to leader. if m . field_type != MsgProp && m . field_type != MsgReadIndex { m . term = self . term ; } } self . msgs . push ( m ) ; }
persists state to stable storage and then sends to its mailbox.
persists state to stable storage and then sends to its mailbox .
&mut self
m
Message