From 8d94567317ee5074f112611cf9d7f63d4335889f Mon Sep 17 00:00:00 2001 From: NoelBright Date: Fri, 28 Sep 2018 19:04:34 +0800 Subject: [PATCH] modify HandleMindChangingMsg mechanism 1. add vote for block only whein contenttype is BlockVote. 2. return when MindChangingMsg is higher than current voting. Signed-off-by: NoelBright --- consensus/ising/proposerservice.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/consensus/ising/proposerservice.go b/consensus/ising/proposerservice.go index 9c1dae5d6..9e80df766 100644 --- a/consensus/ising/proposerservice.go +++ b/consensus/ising/proposerservice.go @@ -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 }