From a08826cd9cd43c27866d52edf4a71cf85d44656b Mon Sep 17 00:00:00 2001 From: Tobias Schottdorf Date: Wed, 19 Jun 2019 12:44:07 +0200 Subject: [PATCH] fixup! rename some variables --- raft/quorum/datadriven_test.go | 34 +++++++++++++++++----------------- raft/quorum/joint.go | 10 +++++----- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/raft/quorum/datadriven_test.go b/raft/quorum/datadriven_test.go index 3f647a4d698f..58bfd7234caa 100644 --- a/raft/quorum/datadriven_test.go +++ b/raft/quorum/datadriven_test.go @@ -168,20 +168,20 @@ func TestDataDriven(t *testing.T) { // Branch based on whether this is a majority or joint quorum // test case. if !joint { - cr := c.CommittedIndex(l) + idx := c.CommittedIndex(l) fmt.Fprintf(&buf, c.Describe(l)) // These alternative computations should return the same // result. If not, print to the output. - if acr := alternativeMajorityCommittedIndex(c, l); acr != cr { - fmt.Fprintf(&buf, "%s <-- via alternative computation\n", acr) + if aIdx := alternativeMajorityCommittedIndex(c, l); aIdx != idx { + fmt.Fprintf(&buf, "%s <-- via alternative computation\n", aIdx) } // Joining a majority with the empty majority should give same result. - if acr := JointConfig([2]MajorityConfig{c, {}}).CommittedIndex(l); acr != cr { - fmt.Fprintf(&buf, "%s <-- via zero-joint quorum\n", acr) + if aIdx := JointConfig([2]MajorityConfig{c, {}}).CommittedIndex(l); aIdx != idx { + fmt.Fprintf(&buf, "%s <-- via zero-joint quorum\n", aIdx) } // Joining a majority with itself should give same result. - if acr := JointConfig([2]MajorityConfig{c, c}).CommittedIndex(l); acr != cr { - fmt.Fprintf(&buf, "%s <-- via self-joint quorum\n", acr) + if aIdx := JointConfig([2]MajorityConfig{c, c}).CommittedIndex(l); aIdx != idx { + fmt.Fprintf(&buf, "%s <-- via self-joint quorum\n", aIdx) } overlay := func(c MajorityConfig, l AckedIndexer, id uint64, idx Index) AckedIndexer { ll := mapAckIndexer{} @@ -196,30 +196,30 @@ func TestDataDriven(t *testing.T) { } for id := range c { idx, _ := l.AckedIndex(id) - if cr > idx && idx > 0 { + if idx > idx && idx > 0 { // If the committed index was definitely above the currently // inspected idx, the result shouldn't change if we lower it // further. lo := overlay(c, l, id, idx-1) - if cro := c.CommittedIndex(lo); cro != cr { - fmt.Fprintf(&buf, "%s <-- overlaying %d->%d", cro, id, idx) + if aIdx := c.CommittedIndex(lo); aIdx != idx { + fmt.Fprintf(&buf, "%s <-- overlaying %d->%d", aIdx, id, idx) } lo = overlay(c, l, id, 0) - if cro := c.CommittedIndex(lo); cro != cr { - fmt.Fprintf(&buf, "%s <-- overlaying %d->0", cro, id) + if aIdx := c.CommittedIndex(lo); aIdx != idx { + fmt.Fprintf(&buf, "%s <-- overlaying %d->0", aIdx, id) } } } - fmt.Fprintf(&buf, "%s\n", cr) + fmt.Fprintf(&buf, "%s\n", idx) } else { cc := JointConfig([2]MajorityConfig{c, cj}) fmt.Fprintf(&buf, cc.Describe(l)) - cr := cc.CommittedIndex(l) + idx := cc.CommittedIndex(l) // Interchanging the majorities shouldn't make a difference. If it does, print. - if acr := JointConfig([2]MajorityConfig{c, cj}).CommittedIndex(l); acr != cr { - fmt.Fprintf(&buf, "%s <-- via symmetry\n", acr) + if aIdx := JointConfig([2]MajorityConfig{c, cj}).CommittedIndex(l); aIdx != idx { + fmt.Fprintf(&buf, "%s <-- via symmetry\n", aIdx) } - fmt.Fprintf(&buf, "%s\n", cr) + fmt.Fprintf(&buf, "%s\n", idx) } case "vote": ll := makeLookuper(votes, ids, idsj) diff --git a/raft/quorum/joint.go b/raft/quorum/joint.go index 947a68c5b435..9f8f484dc571 100644 --- a/raft/quorum/joint.go +++ b/raft/quorum/joint.go @@ -40,12 +40,12 @@ func (c JointConfig) Describe(l AckedIndexer) string { // quorum. An index is jointly committed if it is committed in both constituent // majorities. func (c JointConfig) CommittedIndex(l AckedIndexer) Index { - cl := c[0].CommittedIndex(l) - cr := c[1].CommittedIndex(l) - if cl < cr { - return cl + idx0 := c[0].CommittedIndex(l) + idx1 := c[1].CommittedIndex(l) + if idx0 < idx1 { + return idx0 } - return cr + return idx1 } // VoteResult takes a mapping of voters to yes/no (true/false) votes and returns