diff --git a/consensus/consensus.go b/consensus/consensus.go index 12a6d71bb..e84661efd 100644 --- a/consensus/consensus.go +++ b/consensus/consensus.go @@ -311,12 +311,6 @@ func (cs *consensus) AddVote(vte *vote.Vote) { cs.logger.Info("new vote added", "vote", vte) cs.currentState.onAddVote(vte) - - if vte.Type() == vote.VoteTypeCPDecided { - if vte.Round() > cs.round { - cs.changeProposer.cpDecide(vte.Round(), vte.CPValue()) - } - } } } diff --git a/consensus/cp.go b/consensus/cp.go index b61345e88..600eb51c8 100644 --- a/consensus/cp.go +++ b/consensus/cp.go @@ -313,26 +313,19 @@ func (cp *changeProposer) checkJust(vte *vote.Vote) error { func (cp *changeProposer) cpStrongTermination() { cpDecided := cp.log.CPDecidedVoteSet(cp.round) if cpDecided.HasAnyVoteFor(cp.cpRound, vote.CPValueNo) { - cp.cpDecide(cp.round, vote.CPValueNo) - } else if cpDecided.HasAnyVoteFor(cp.cpRound, vote.CPValueYes) { - cp.cpDecide(cp.round, vote.CPValueYes) - } -} - -func (cp *changeProposer) cpDecide(round int16, cpValue vote.CPValue) { - if cpValue == vote.CPValueYes { - cp.round = round + 1 - cp.cpDecided = 1 - cp.enterNewState(cp.proposeState) - } else if cpValue == vote.CPValueNo { - cp.round = round cp.cpDecided = 0 roundProposal := cp.log.RoundProposal(cp.round) if roundProposal == nil { cp.queryProposal() } - cp.enterNewState(cp.prepareState) + } else if cpDecided.HasAnyVoteFor(cp.cpRound, vote.CPValueYes) { + cp.round++ + cp.cpDecided = 1 + cp.enterNewState(cp.proposeState) + + // Check if there is any decided vote for the next round. + cp.cpStrongTermination() } } diff --git a/consensus/cp_decide.go b/consensus/cp_decide.go index 8f87ad6a4..07d82b914 100644 --- a/consensus/cp_decide.go +++ b/consensus/cp_decide.go @@ -26,7 +26,6 @@ func (s *cpDecideState) decide() { QCert: cert, } s.signAddCPDecidedVote(hash.UndefHash, s.cpRound, vote.CPValueYes, just) - s.cpDecide(s.round, vote.CPValueYes) } else if cpMainVotes.HasQuorumVotesFor(s.cpRound, vote.CPValueNo) { // decided for no and proceeds to the next round s.logger.Info("binary agreement decided", "value", 0, "round", s.cpRound) @@ -37,7 +36,6 @@ func (s *cpDecideState) decide() { QCert: cert, } s.signAddCPDecidedVote(*s.cpWeakValidity, s.cpRound, vote.CPValueNo, just) - s.cpDecide(s.round, vote.CPValueNo) } else { // conflicting votes s.logger.Debug("conflicting main votes", "round", s.cpRound)