From 5c212022afcf78e60593c3597204215416d49953 Mon Sep 17 00:00:00 2001 From: Fullstop000 Date: Sun, 1 Mar 2020 23:23:11 +0800 Subject: [PATCH] make revive happy Signed-off-by: Fullstop000 --- raft/group.go | 3 +-- raft/group_test.go | 2 +- raft/raft.go | 19 +++++++++---------- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/raft/group.go b/raft/group.go index c099dc99c0d4..0854ffe49549 100644 --- a/raft/group.go +++ b/raft/group.go @@ -74,9 +74,8 @@ func (g *Groups) GetMemberInfo(member uint64) *MemberInfo { func (g *Groups) GetDelegate(peer uint64) uint64 { if info, ok := g.Indexes[peer]; ok { return info.Delegate - } else { - return None } + return None } // pickDelegate picks a delegate who has the biggest `match` among the same group of given `to` diff --git a/raft/group_test.go b/raft/group_test.go index fd22ec378f8e..aed000426f33 100644 --- a/raft/group_test.go +++ b/raft/group_test.go @@ -48,7 +48,7 @@ func TestGroupSystem(t *testing.T) { } groups.LeaderGroupID = 1 prs := tracker.MakeProgressTracker(256) - for i := 1; i <= 6; i += 1 { + for i := 1; i <= 6; i++ { prs.Progress[uint64(i)] = &tracker.Progress{ Match: 99, Next: 100, diff --git a/raft/raft.go b/raft/raft.go index 03962cb4ed73..4c739f99df0c 100644 --- a/raft/raft.go +++ b/raft/raft.go @@ -1418,17 +1418,16 @@ func (r *raft) handleAppendEntries(m pb.Message) bool { r.send(toSend) } return true - } else { - r.logger.Debugf("%x [logterm: %d, index: %d] rejected MsgApp [logterm: %d, index: %d] from %x", - r.id, r.raftLog.zeroTermOnErrCompacted(r.raftLog.term(m.Index)), m.Index, m.LogTerm, m.Index, m.From) - toSend.Reject = true - toSend.RejectHint = r.raftLog.lastIndex() - if msgFromDelegate(&m) { - toSend.To = m.Delegate - } - r.send(toSend) - return false } + r.logger.Debugf("%x [logterm: %d, index: %d] rejected MsgApp [logterm: %d, index: %d] from %x", + r.id, r.raftLog.zeroTermOnErrCompacted(r.raftLog.term(m.Index)), m.Index, m.LogTerm, m.Index, m.From) + toSend.Reject = true + toSend.RejectHint = r.raftLog.lastIndex() + if msgFromDelegate(&m) { + toSend.To = m.Delegate + } + r.send(toSend) + return false } func (r *raft) handleAppendResponse(pr *tracker.Progress, m pb.Message) (bool, bool) {