From 632ac41d79de892f27ae41d80a8ae07422fd7f9f Mon Sep 17 00:00:00 2001 From: Jeremiah Andrews Date: Thu, 9 Aug 2018 12:43:23 -0700 Subject: [PATCH] Fix minor issues for review --- consensus/replay_test.go | 10 ++++------ lite/helpers.go | 6 +++--- types/block.go | 18 +++++++++--------- 3 files changed, 16 insertions(+), 18 deletions(-) diff --git a/consensus/replay_test.go b/consensus/replay_test.go index 8121f0066..f4cbcd73b 100644 --- a/consensus/replay_test.go +++ b/consensus/replay_test.go @@ -550,12 +550,10 @@ func makeBlockchainFromWAL(wal WAL) ([]*types.Block, []*types.Commit, error) { if p.Type == types.VoteTypePrecommit { thisBlockCommit = &types.Commit{ BlockID: p.BlockID, - Precommits: []*types.CommitSig{ - &types.CommitSig{ - Signature: p.Signature, - Timestamp: p.Timestamp, - }, - }, + Precommits: []*types.CommitSig{{ + Signature: p.Signature, + Timestamp: p.Timestamp, + }}, HeightNum: p.Height, RoundNum: p.Round, } diff --git a/lite/helpers.go b/lite/helpers.go index 6feecfabd..8d6865927 100644 --- a/lite/helpers.go +++ b/lite/helpers.go @@ -71,7 +71,7 @@ func (pkz privKeys) ToValidators(init, inc int64) *types.ValidatorSet { // signHeader properly signs the header with all keys from first to last exclusive. func (pkz privKeys) signHeader(header *types.Header, first, last int) *types.Commit { - cs := make([]*types.CommitSig, len(pkz)) + commitSigs := make([]*types.CommitSig, len(pkz)) // We need this list to keep the ordering. vset := pkz.ToValidators(1, 0) @@ -79,7 +79,7 @@ func (pkz privKeys) signHeader(header *types.Header, first, last int) *types.Com // Fill in the votes we want. for i := first; i < last && i < len(pkz); i++ { vote := makeVote(header, vset, pkz[i]) - cs[vote.ValidatorIndex] = &types.CommitSig{ + commitSigs[vote.ValidatorIndex] = &types.CommitSig{ Signature: vote.Signature, Timestamp: vote.Timestamp, } @@ -87,7 +87,7 @@ func (pkz privKeys) signHeader(header *types.Header, first, last int) *types.Com res := &types.Commit{ BlockID: types.BlockID{Hash: header.Hash()}, - Precommits: cs, + Precommits: commitSigs, RoundNum: 1, HeightNum: header.Height, } diff --git a/types/block.go b/types/block.go index fc9332037..a204fa495 100644 --- a/types/block.go +++ b/types/block.go @@ -311,13 +311,13 @@ type CommitSig struct { Timestamp time.Time } -func (cs *CommitSig) String(index int, address Address, height int64, round int, blockID BlockID) string { +func (commitSig *CommitSig) String(index int, address Address, height int64, round int, blockID BlockID) string { return fmt.Sprintf("Vote{%v:%X %v/%02d/%v(%v) %X %X @ %s}", index, cmn.Fingerprint(address), height, round, VoteTypePrecommit, "Precommit", cmn.Fingerprint(blockID.Hash), - cmn.Fingerprint(cs.Signature), - CanonicalTime(cs.Timestamp)) + cmn.Fingerprint(commitSig.Signature), + CanonicalTime(commitSig.Timestamp)) } // Height returns the height of the commit @@ -357,15 +357,15 @@ func (commit *Commit) BitArray() *cmn.BitArray { } // GetByIndex returns the vote corresponding to a given validator index -func (com *Commit) GetByIndex(index int) *Vote { +func (commit *Commit) GetByIndex(index int) *Vote { return &Vote{ ValidatorIndex: index, - Height: com.HeightNum, - Round: com.RoundNum, - Timestamp: com.Precommits[index].Timestamp, + Height: commit.HeightNum, + Round: commit.RoundNum, + Timestamp: commit.Precommits[index].Timestamp, Type: VoteTypePrecommit, - BlockID: com.BlockID, - Signature: com.Precommits[index].Signature, + BlockID: commit.BlockID, + Signature: commit.Precommits[index].Signature, } }