Addressing review comments

This commit is contained in:
Jeremiah Andrews 2018-08-27 18:42:01 -07:00
parent e5965ababe
commit 43d40ee489
9 changed files with 14 additions and 13 deletions

View File

@ -629,7 +629,7 @@ OUTER_LOOP:
// Load the block commit for prs.Height,
// which contains precommit signatures for prs.Height.
commit := conR.conS.blockStore.LoadBlockCommit(prs.Height)
commit.AddAddresses(conR.conS.Validators.GetAddresses())
commit.SetAddresses(conR.conS.Validators.GetAddresses())
if ps.PickSendVote(commit) {
logger.Debug("Picked Catchup commit to send", "height", prs.Height)
continue OUTER_LOOP

View File

@ -452,7 +452,7 @@ func (cs *ConsensusState) reconstructLastCommit(state sm.State) {
return
}
seenCommit := cs.blockStore.LoadSeenCommit(state.LastBlockHeight)
seenCommit.AddAddresses(cs.Validators.GetAddresses())
seenCommit.SetAddresses(cs.Validators.GetAddresses())
lastPrecommits := types.NewVoteSet(state.ChainID, state.LastBlockHeight, seenCommit.Round(), types.VoteTypePrecommit, state.LastValidators)
for idx := 0; idx < len(seenCommit.Precommits); idx++ {
if seenCommit.Precommits[idx] == nil {

View File

@ -294,6 +294,7 @@ func TestStateFullRoundNil(t *testing.T) {
validatePrevoteAndPrecommit(t, cs, round, 0, vss[0], nil, nil)
}
// Tests that consensus state can be saved and reloaded from DB after committing a block.
func TestStateFullRound1Reload(t *testing.T) {
blockDB := dbm.NewMemDB()
state, privVals := randGenesisState(1, false, 10)

View File

@ -26,7 +26,7 @@ func BenchmarkRoundStateDeepCopy(b *testing.B) {
sig := make([]byte, ed25519.SignatureSize)
for i := 0; i < nval; i++ {
precommits[i] = &types.CommitSig{
Timestamp: time.Now(),
Timestamp: time.Now().UTC(),
Signature: sig,
}
}
@ -38,7 +38,7 @@ func BenchmarkRoundStateDeepCopy(b *testing.B) {
block := &types.Block{
Header: types.Header{
ChainID: cmn.RandStr(12),
Time: time.Now(),
Time: time.Now().UTC(),
LastBlockID: blockID,
LastCommitHash: cmn.RandBytes(20),
DataHash: cmn.RandBytes(20),
@ -60,7 +60,7 @@ func BenchmarkRoundStateDeepCopy(b *testing.B) {
parts := block.MakePartSet(4096)
// Random Proposal
proposal := &types.Proposal{
Timestamp: time.Now(),
Timestamp: time.Now().UTC(),
BlockPartsHeader: types.PartSetHeader{
Hash: cmn.RandBytes(20),
},
@ -71,8 +71,8 @@ func BenchmarkRoundStateDeepCopy(b *testing.B) {
// TODO: hvs :=
rs := &RoundState{
StartTime: time.Now(),
CommitTime: time.Now(),
StartTime: time.Now().UTC(),
CommitTime: time.Now().UTC(),
Validators: vset,
Proposal: proposal,
ProposalBlock: block,

View File

@ -117,8 +117,8 @@ height and round by a sufficient set of validators.
type Commit struct {
HeightNum int64
RoundNum int
BlockID BlockID
Precommits []*CommitSig
BlockID BlockID
Precommits []*CommitSig
}
```

View File

@ -129,7 +129,7 @@ func (p *provider) fillFullCommit(signedHeader types.SignedHeader) (fc lite.Full
if err != nil {
return lite.FullCommit{}, err
}
signedHeader.Commit.AddAddresses(valset.GetAddresses())
signedHeader.Commit.SetAddresses(valset.GetAddresses())
return lite.NewFullCommit(signedHeader, valset, nextValset), nil
}

View File

@ -177,7 +177,7 @@ func (dbp *DBProvider) fillFullCommit(sh types.SignedHeader) (FullCommit, error)
if err != nil {
return FullCommit{}, err
}
sh.Commit.AddAddresses(valset.GetAddresses())
sh.Commit.SetAddresses(valset.GetAddresses())
// Return filled FullCommit.
return FullCommit{
SignedHeader: sh,

View File

@ -384,7 +384,7 @@ func (commit *Commit) BitArray() *cmn.BitArray {
return commit.bitArray
}
func (commit *Commit) AddAddresses(addresses []Address) {
func (commit *Commit) SetAddresses(addresses []Address) {
commit.addresses = addresses
}

View File

@ -278,7 +278,7 @@ func (vals *ValidatorSet) VerifyCommit(chainID string, blockID BlockID, height i
}
talliedVotingPower := int64(0)
commit.AddAddresses(vals.GetAddresses())
commit.SetAddresses(vals.GetAddresses())
for idx, precommit := range commit.Precommits {
if precommit == nil {