Add more comments for Valid*

This commit is contained in:
Jae Kwon 2018-05-12 17:42:37 -07:00
parent b9c95ac546
commit 48dd1c328c
2 changed files with 11 additions and 10 deletions

View File

@ -1307,19 +1307,20 @@ func (cs *ConsensusState) addProposalBlockPart(height int64, part *types.Part, v
// NOTE: it's possible to receive complete proposal blocks for future rounds without having the proposal
cs.Logger.Info("Received complete proposal block", "height", cs.ProposalBlock.Height, "hash", cs.ProposalBlock.Hash())
// Update ValidBlock
// Update Valid* if we can.
prevotes := cs.Votes.Prevotes(cs.Round)
blockID, ok := prevotes.TwoThirdsMajority()
if ok && !blockID.IsZero() && (cs.ValidRound < cs.Round) {
// update valid value
blockID, hasTwoThirds := prevotes.TwoThirdsMajority()
if hasTwoThirds && !blockID.IsZero() && (cs.ValidRound < cs.Round) {
if cs.ProposalBlock.HashesTo(blockID.Hash) {
cs.ValidRound = cs.Round
cs.ValidBlock = cs.ProposalBlock
cs.ValidBlockParts = cs.ProposalBlockParts
}
//TODO: In case there is +2/3 majority in Prevotes set for some block and cs.ProposalBlock contains different block,
//either proposer is faulty or voting power of faulty processes is more than 1/3. We should
//trigger in the future accountability procedure at this point.
// TODO: In case there is +2/3 majority in Prevotes set for some
// block and cs.ProposalBlock contains different block, either
// proposer is faulty or voting power of faulty processes is more
// than 1/3. We should trigger in the future accountability
// procedure at this point.
}
if cs.Step == cstypes.RoundStepPropose && cs.isProposalComplete() {

View File

@ -67,9 +67,9 @@ type RoundState struct {
LockedRound int
LockedBlock *types.Block
LockedBlockParts *types.PartSet
ValidRound int
ValidBlock *types.Block
ValidBlockParts *types.PartSet
ValidRound int // Last known round with POL for non-nil valid block.
ValidBlock *types.Block // Last known block of POL mentioned above.
ValidBlockParts *types.PartSet // Last known block parts of POL metnioned above.
Votes *HeightVoteSet
CommitRound int //
LastCommit *types.VoteSet // Last precommits at Height-1