diff --git a/consensus/reactor.go b/consensus/reactor.go index 40026f445..a4381bf1a 100644 --- a/consensus/reactor.go +++ b/consensus/reactor.go @@ -383,8 +383,10 @@ OUTER_LOOP: prs := ps.GetRoundState() trySendVote := func(voteSet *VoteSet, peerVoteSet BitArray) (sent bool) { - // Initialize Prevotes/Precommits/Commits if needed - ps.EnsureVoteBitArrays(prs.Height, voteSet.Size()) + if prs.Height == voteSet.Height() { + // Initialize Prevotes/Precommits/Commits if needed + ps.EnsureVoteBitArrays(prs.Height, voteSet.Size()) + } // TODO: give priority to our vote. if index, ok := voteSet.BitArray().Sub(peerVoteSet.Copy()).PickRandom(); ok { diff --git a/consensus/vote_set.go b/consensus/vote_set.go index 03e63d3b8..9bf098cb6 100644 --- a/consensus/vote_set.go +++ b/consensus/vote_set.go @@ -54,6 +54,14 @@ func NewVoteSet(height uint, round uint, type_ byte, valSet *sm.ValidatorSet) *V } } +func (voteSet *VoteSet) Height() uint { + if voteSet == nil { + return 0 + } else { + return voteSet.height + } +} + func (voteSet *VoteSet) Size() uint { if voteSet == nil { return 0