update some comments

This commit is contained in:
Ethan Buchman 2018-05-14 16:32:19 -04:00
parent b5ac9ede8a
commit 162811476a
3 changed files with 11 additions and 11 deletions

View File

@ -1427,11 +1427,12 @@ func (cs *ConsensusState) addVote(vote *types.Vote, peerID p2p.ID) (added bool,
// If +2/3 prevotes for a block or nil for *any* round: // If +2/3 prevotes for a block or nil for *any* round:
if blockID, ok := prevotes.TwoThirdsMajority(); ok { if blockID, ok := prevotes.TwoThirdsMajority(); ok {
// First, unlock if prevotes is a valid POL. // There was a polka!
// `lockRound < POLRound <= unlockOrChangeLockRound (see spec)` // If we're locked but this is a recent polka, unlock.
// NOTE: If `lockRound < POLRound` but `!(POLRound <= // If it matches our ProposalBlock, update the ValidBlock
// unlockOrChangeLockRound)`, we'll still enterNewRound(H,vote.R)
// and enterPrecommit(H,vote.R) to process it there. // Unlock if `cs.LockedRound < vote.Round <= cs.Round`
// NOTE: If vote.Round > cs.Round, we'll deal with it when we get to vote.Round
if (cs.LockedBlock != nil) && if (cs.LockedBlock != nil) &&
(cs.LockedRound < vote.Round) && (cs.LockedRound < vote.Round) &&
(vote.Round <= cs.Round) && (vote.Round <= cs.Round) &&
@ -1445,6 +1446,8 @@ func (cs *ConsensusState) addVote(vote *types.Vote, peerID p2p.ID) (added bool,
} }
// Update Valid* if we can. // Update Valid* if we can.
// NOTE: our proposal block may be nil or not what received a polka..
// TODO: we may want to still update the ValidBlock and obtain it via gossipping
if !blockID.IsZero() && if !blockID.IsZero() &&
(cs.ValidRound < vote.Round) && (cs.ValidRound < vote.Round) &&
(vote.Round <= cs.Round) && (vote.Round <= cs.Round) &&
@ -1453,9 +1456,6 @@ func (cs *ConsensusState) addVote(vote *types.Vote, peerID p2p.ID) (added bool,
cs.ValidRound = vote.Round cs.ValidRound = vote.Round
cs.ValidBlock = cs.ProposalBlock cs.ValidBlock = cs.ProposalBlock
cs.ValidBlockParts = cs.ProposalBlockParts cs.ValidBlockParts = cs.ProposalBlockParts
// TODO: We might want to update ValidBlock also in case we
// don't have that block yet, and obtain the required block
// using gossiping
} }
} }

View File

@ -124,7 +124,7 @@ func (b *Block) MakePartSet(partSize int) *PartSet {
} }
// HashesTo is a convenience function that checks if a block hashes to the given argument. // HashesTo is a convenience function that checks if a block hashes to the given argument.
// A nil block never hashes to anything, and nothing hashes to a nil hash. // Returns false if the block is nil or the hash is empty.
func (b *Block) HashesTo(hash []byte) bool { func (b *Block) HashesTo(hash []byte) bool {
if len(hash) == 0 { if len(hash) == 0 {
return false return false

View File

@ -404,8 +404,8 @@ func (voteSet *VoteSet) HasAll() bool {
return voteSet.sum == voteSet.valSet.TotalVotingPower() return voteSet.sum == voteSet.valSet.TotalVotingPower()
} }
// Returns either a blockhash (or nil) that received +2/3 majority. // If there was a +2/3 majority for blockID, return blockID and true.
// If there exists no such majority, returns (nil, PartSetHeader{}, false). // Else, return the empty BlockID{} and false.
func (voteSet *VoteSet) TwoThirdsMajority() (blockID BlockID, ok bool) { func (voteSet *VoteSet) TwoThirdsMajority() (blockID BlockID, ok bool) {
if voteSet == nil { if voteSet == nil {
return BlockID{}, false return BlockID{}, false