Ensure correct peer vote bitarray capacity

This commit is contained in:
Jae Kwon
2015-01-16 02:49:15 -08:00
parent d1a36d2ac2
commit 165907fbb9
2 changed files with 12 additions and 2 deletions

View File

@@ -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 {

View File

@@ -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