Browse Source

...

pull/67/head
Jae Kwon 10 years ago
parent
commit
c3a12e3cb8
1 changed files with 6 additions and 11 deletions
  1. +6
    -11
      consensus/reactor.go

+ 6
- 11
consensus/reactor.go View File

@ -433,6 +433,7 @@ OUTER_LOOP:
return
}
rs := conR.conS.GetRoundState()
ps.EnsureVoteBitArrays(rs.Height, rs.Validators.Size())
prs := ps.GetRoundState()
switch sleeping {
@ -443,11 +444,6 @@ OUTER_LOOP:
}
trySendVote := func(voteSet *VoteSet, peerVoteSet *BitArray) (sent bool) {
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 {
vote := voteSet.GetByIndex(index)
@ -461,9 +457,6 @@ OUTER_LOOP:
}
trySendCommitFromValidation := func(blockMeta *types.BlockMeta, validation *types.Validation, peerVoteSet *BitArray) (sent bool) {
// Initialize Commits if needed
ps.EnsureVoteBitArrays(prs.Height, uint(len(validation.Commits)))
if index, ok := validation.BitArray().Sub(prs.Commits.Copy()).PickRandom(); ok {
commit := validation.Commits[index]
log.Debug("Picked commit to send", "index", index, "commit", commit)
@ -489,9 +482,11 @@ OUTER_LOOP:
// If there are lastcommits to send...
if prs.Round == 0 && prs.Step == RoundStepNewHeight {
if prs.LastCommits.Size() == rs.LastCommits.Size() {
if trySendVote(rs.LastCommits, prs.LastCommits) {
continue OUTER_LOOP
if prs.LastCommits != nil && rs.LastCommits != nil {
if prs.LastCommits.Size() == rs.LastCommits.Size() {
if trySendVote(rs.LastCommits, prs.LastCommits) {
continue OUTER_LOOP
}
}
}
}


Loading…
Cancel
Save