Browse Source

Do not wipe cs.Votes upon SwitchToConsensus

pull/102/head
Jae Kwon 10 years ago
parent
commit
f325675b83
3 changed files with 13 additions and 1 deletions
  1. +2
    -0
      consensus/height_vote_set.go
  2. +3
    -1
      consensus/reactor.go
  3. +8
    -0
      consensus/state.go

+ 2
- 0
consensus/height_vote_set.go View File

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


+ 3
- 1
consensus/reactor.go View File

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


+ 8
- 0
consensus/state.go View File

@ -400,6 +400,14 @@ func (cs *ConsensusState) updateToState(state *sm.State, contiguous bool) {
} }
// END SANITY CHECK // 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. // Reset fields based on state.
validators := state.BondedValidators validators := state.BondedValidators
height := state.LastBlockHeight + 1 // next desired block height height := state.LastBlockHeight + 1 // next desired block height


Loading…
Cancel
Save