|
@ -396,26 +396,30 @@ OUTER_LOOP: |
|
|
// which contains commit signatures for prs.Height.
|
|
|
// which contains commit signatures for prs.Height.
|
|
|
header, validation := conR.conS.LoadHeaderValidation(prs.Height + 1) |
|
|
header, validation := conR.conS.LoadHeaderValidation(prs.Height + 1) |
|
|
size := uint(len(validation.Commits)) |
|
|
size := uint(len(validation.Commits)) |
|
|
|
|
|
log.Debug("Loaded HeaderValidation for catchup", "height", prs.Height+1, "header", header, "validation", validation, "size", size) |
|
|
|
|
|
|
|
|
// Initialize Commits if needed
|
|
|
// Initialize Commits if needed
|
|
|
ps.EnsureVoteBitArrays(prs.Height, size) |
|
|
ps.EnsureVoteBitArrays(prs.Height, size) |
|
|
|
|
|
|
|
|
index, ok := validation.BitArray().Sub(prs.Commits).PickRandom() |
|
|
index, ok := validation.BitArray().Sub(prs.Commits).PickRandom() |
|
|
if ok { |
|
|
if ok { |
|
|
rsig := validation.Commits[index] |
|
|
|
|
|
|
|
|
commit := validation.Commits[index] |
|
|
|
|
|
log.Debug("Picked commit to send", "index", index, "commit", commit) |
|
|
// Reconstruct vote.
|
|
|
// Reconstruct vote.
|
|
|
vote := &Vote{ |
|
|
vote := &Vote{ |
|
|
Height: prs.Height, |
|
|
Height: prs.Height, |
|
|
Round: rsig.Round, |
|
|
|
|
|
|
|
|
Round: commit.Round, |
|
|
Type: VoteTypeCommit, |
|
|
Type: VoteTypeCommit, |
|
|
BlockHash: header.LastBlockHash, |
|
|
BlockHash: header.LastBlockHash, |
|
|
BlockParts: header.LastBlockParts, |
|
|
BlockParts: header.LastBlockParts, |
|
|
Signature: rsig.Signature, |
|
|
|
|
|
|
|
|
Signature: commit.Signature, |
|
|
} |
|
|
} |
|
|
msg := &VoteMessage{index, vote} |
|
|
msg := &VoteMessage{index, vote} |
|
|
peer.Send(VoteCh, msg) |
|
|
peer.Send(VoteCh, msg) |
|
|
ps.SetHasVote(vote, index) |
|
|
ps.SetHasVote(vote, index) |
|
|
continue OUTER_LOOP |
|
|
continue OUTER_LOOP |
|
|
|
|
|
} else { |
|
|
|
|
|
log.Debug("No commits to send", "ours", validation.BitArray(), "theirs", prs.Commits) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|