Do not wipe cs.Votes upon SwitchToConsensus

This commit is contained in:
Jae Kwon
2015-07-05 21:19:47 -07:00
parent 1a1b9aaaab
commit f325675b83
3 changed files with 13 additions and 1 deletions

View File

@@ -78,6 +78,7 @@ func (hvs *HeightVoteSet) addRound(round int) {
if _, ok := hvs.roundVoteSets[round]; ok {
panic("addRound() for an existing round")
}
log.Debug("addRound(round)", "round", round)
prevotes := NewVoteSet(hvs.height, round, types.VoteTypePrevote, hvs.valSet)
precommits := NewVoteSet(hvs.height, round, types.VoteTypePrecommit, hvs.valSet)
hvs.roundVoteSets[round] = RoundVoteSet{
@@ -134,6 +135,7 @@ func (hvs *HeightVoteSet) POLRound() int {
}
func (hvs *HeightVoteSet) getVoteSet(round int, type_ byte) *VoteSet {
log.Debug("getVoteSet(round)", "round", round, "type", type_)
rvs, ok := hvs.roundVoteSets[round]
if !ok {
return nil

View File

@@ -67,7 +67,7 @@ func (conR *ConsensusReactor) Start(sw *p2p.Switch) {
conR.conS.Start()
}
go conR.broadcastNewRoundStepRoutine()
go conR.rebroadcastRoundStepRoutine()
// go conR.rebroadcastRoundStepRoutine()
}
}
@@ -322,6 +322,7 @@ func (conR *ConsensusReactor) broadcastNewRoundStepRoutine() {
}
}
/* TODO delete
// Periodically broadcast NewRoundStepMessage.
// This is a hack. TODO remove the need for it?
// The issue is with Start() happening after a NewRoundStep message
@@ -339,6 +340,7 @@ func (conR *ConsensusReactor) rebroadcastRoundStepRoutine() {
}
}
}
*/
func (conR *ConsensusReactor) sendNewRoundStepMessage(peer *p2p.Peer) {
rs := conR.conS.GetRoundState()

View File

@@ -400,6 +400,14 @@ func (cs *ConsensusState) updateToState(state *sm.State, contiguous bool) {
}
// END SANITY CHECK
// If state isn't further out than cs.state, just ignore.
// This happens when SwitchToConsensus() is called in the reactor.
// We don't want to reset e.g. the Votes.
if cs.state != nil && (state.LastBlockHeight <= cs.state.LastBlockHeight) {
log.Info("Ignoring updateToState()", "newHeight", state.LastBlockHeight+1, "oldHeight", cs.state.LastBlockHeight+1)
return
}
// Reset fields based on state.
validators := state.BondedValidators
height := state.LastBlockHeight + 1 // next desired block height