Browse Source

fix HeightVoteSet SetRound(0) bug which wipes out Prevotes; More logging for consensus/state addVote()

pull/102/head
Jae Kwon 10 years ago
parent
commit
1a1b9aaaab
2 changed files with 6 additions and 2 deletions
  1. +1
    -1
      consensus/height_vote_set.go
  2. +5
    -1
      consensus/state.go

+ 1
- 1
consensus/height_vote_set.go View File

@ -69,7 +69,7 @@ func (hvs *HeightVoteSet) SetRound(round int) {
if _, ok := hvs.roundVoteSets[r]; ok { if _, ok := hvs.roundVoteSets[r]; ok {
continue // Already exists because peerCatchupRounds. continue // Already exists because peerCatchupRounds.
} }
hvs.addRound(round)
hvs.addRound(r)
} }
hvs.round = round hvs.round = round
} }


+ 5
- 1
consensus/state.go View File

@ -1054,6 +1054,8 @@ func (cs *ConsensusState) AddVote(address []byte, vote *types.Vote, peerKey stri
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
func (cs *ConsensusState) addVote(address []byte, vote *types.Vote, peerKey string) (added bool, index int, err error) { func (cs *ConsensusState) addVote(address []byte, vote *types.Vote, peerKey string) (added bool, index int, err error) {
log.Debug("addVote", "voteHeight", vote.Height, "voteType", vote.Type, "csHeight", cs.Height)
// A precommit for the previous height? // A precommit for the previous height?
if vote.Height+1 == cs.Height && vote.Type == types.VoteTypePrecommit { if vote.Height+1 == cs.Height && vote.Type == types.VoteTypePrecommit {
added, index, err = cs.LastCommit.AddByAddress(address, vote) added, index, err = cs.LastCommit.AddByAddress(address, vote)
@ -1129,10 +1131,12 @@ func (cs *ConsensusState) addVote(address []byte, vote *types.Vote, peerKey stri
panic(Fmt("Unexpected vote type %X", vote.Type)) // Should not happen. panic(Fmt("Unexpected vote type %X", vote.Type)) // Should not happen.
} }
} }
// Either duplicate, or error upon cs.Votes.AddByAddress()
return return
} }
// Height mismatch, bad peer? TODO
// Height mismatch, bad peer?
log.Debug("Vote ignored and not added", "voteHeight", vote.Height, "csHeight", cs.Height)
return return
} }


Loading…
Cancel
Save