Browse Source

Ensure correct peer vote bitarray capacity

pull/39/head
Jae Kwon 10 years ago
parent
commit
165907fbb9
2 changed files with 12 additions and 2 deletions
  1. +4
    -2
      consensus/reactor.go
  2. +8
    -0
      consensus/vote_set.go

+ 4
- 2
consensus/reactor.go 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 {


+ 8
- 0
consensus/vote_set.go 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


Loading…
Cancel
Save