func (r *raft) tickHeartbeat() {
	r.heartbeatElapsed++
	r.electionElapsed++

	if r.electionElapsed >= r.electionTimeout {
		r.electionElapsed = 0
		if r.checkQuorum {
			r.Step(pb.Message{From: r.id, Type: pb.MsgCheckQuorum})
		}
		// If current leader cannot transfer leadership in electionTimeout, it becomes leader again.
		if r.state == StateLeader && r.leadTransferee != None {
			r.abortLeaderTransfer()
		}
	}

	if r.state != StateLeader {
		return
	}

	if r.heartbeatElapsed >= r.heartbeatTimeout {
		r.heartbeatElapsed = 0
		r.Step(pb.Message{From: r.id, Type: pb.MsgBeat})
	}
}
func (r *raft) tickHeartbeat() {
	r.heartbeatElapsed++
	r.electionElapsed++

	if r.electionElapsed >= r.electionTimeout {
		r.electionElapsed = 0
		if r.checkQuorum {
			r.Step(pb.Message{From: r.id, Type: pb.MsgCheckQuorum})
		}
		
		if r.state == StateLeader && r.leadTransferee != None {
			r.abortLeaderTransfer()
		}
	}

	if r.state != StateLeader {
		return
	}

	if r.heartbeatElapsed >= r.heartbeatTimeout {
		r.heartbeatElapsed = 0
		r.Step(pb.Message{From: r.id, Type: pb.MsgBeat})
	}
}
func ( r * raft ) tickHeartbeat ( ) { r . heartbeatElapsed ++ r . electionElapsed ++ if r . electionElapsed >= r . electionTimeout { r . electionElapsed = 0 if r . checkQuorum { r . Step ( pb . Message { From : r . id , Type : pb . MsgCheckQuorum } ) } // If current leader cannot transfer leadership in electionTimeout, it becomes leader again. if r . state == StateLeader && r . leadTransferee != None { r . abortLeaderTransfer ( ) } } if r . state != StateLeader { return } if r . heartbeatElapsed >= r . heartbeatTimeout { r . heartbeatElapsed = 0 r . Step ( pb . Message { From : r . id , Type : pb . MsgBeat } ) } }
// tickHeartbeat is run by leaders to send a MsgBeat after r.heartbeatTimeout.
tickHeartbeat is run by leaders to send a MsgBeat after r . heartbeatTimeout .