Skip to content

Commit

Permalink
modify HandleMindChangingMsg mechanism
Browse files Browse the repository at this point in the history
1. add vote for block only whein contenttype is BlockVote.
2. return when MindChangingMsg is higher than current voting.

Signed-off-by: NoelBright <noel.n.bright@gmail.com>
  • Loading branch information
NoelBright authored and yilunzhang committed Sep 28, 2018
1 parent 9e128a9 commit 8d94567
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions consensus/ising/proposerservice.go
Original file line number Diff line number Diff line change
Expand Up @@ -875,20 +875,22 @@ func (ps *ProposerService) HandleMindChangingMsg(mindChanging *MindChanging, sen

// handle mind changing when block syncing
if ps.localNode.GetSyncState() != protocol.PersistFinished {
ps.syncCache.AddVoteForBlock(hash, height, sender)
if mindChanging.contentType == voting.BlockVote {
ps.syncCache.AddVoteForBlock(hash, height, sender)
}
return
}

current := ps.CurrentVoting(mindChanging.contentType)
votingType := current.VotingType()
votingHeight := current.GetVotingHeight()
if height < votingHeight {
if height != votingHeight {
log.Warnf("receive invalid mind changing, consensus height: %d, mind changing height: %d,"+
" hash: %s", votingHeight, height, BytesToHexString(hash.ToArrayReverse()))
return
}
currentVotingPool := current.GetVotingPool()
if currentVotingPool.HasReceivedVoteFrom(votingHeight, sender) {
if !currentVotingPool.HasReceivedVoteFrom(votingHeight, sender) {
log.Warn("no proposal received before, so mind changing is invalid")
return
}
Expand Down

0 comments on commit 8d94567

Please sign in to comment.