Browse Source

raft: move tick comments into cases

Blake Mizerany 11 years ago
parent
commit
dd94d5d4e8
1 changed files with 2 additions and 3 deletions
  1. 2 3
      raft/node.go

+ 2 - 3
raft/node.go

@@ -66,13 +66,12 @@ func (n *Node) Step(m Message) bool {
 		return false
 		return false
 	}
 	}
 	for _, m := range n.sm.msgs[l:] {
 	for _, m := range n.sm.msgs[l:] {
-		// reset elapsed in two cases:
-		// msgAppResp -> heard from the leader of the same term
-		// msgVoteResp with grant -> heard from the candidate the node voted for
 		switch m.Type {
 		switch m.Type {
 		case msgAppResp:
 		case msgAppResp:
+			// We just heard from the leader of the same term.
 			n.elapsed = 0
 			n.elapsed = 0
 		case msgVoteResp:
 		case msgVoteResp:
+			// We just heard from the candidate the node voted for.
 			if m.Index >= 0 {
 			if m.Index >= 0 {
 				n.elapsed = 0
 				n.elapsed = 0
 			}
 			}