Browse Source

consensus: fix negative timeout; log levels

pull/169/head
Ethan Buchman 9 years ago
parent
commit
c3a8f202ab
2 changed files with 10 additions and 6 deletions
  1. +2
    -3
      consensus/reactor.go
  2. +8
    -3
      consensus/state.go

+ 2
- 3
consensus/reactor.go View File

@ -283,15 +283,14 @@ func (conR *ConsensusReactor) broadcastHasVoteMessage(vote *types.Vote, index in
} }
func makeRoundStepMessages(rs *RoundState) (nrsMsg *NewRoundStepMessage, csMsg *CommitStepMessage) { func makeRoundStepMessages(rs *RoundState) (nrsMsg *NewRoundStepMessage, csMsg *CommitStepMessage) {
step := RoundStepType(rs.Step)
nrsMsg = &NewRoundStepMessage{ nrsMsg = &NewRoundStepMessage{
Height: rs.Height, Height: rs.Height,
Round: rs.Round, Round: rs.Round,
Step: step,
Step: rs.Step,
SecondsSinceStartTime: int(time.Now().Sub(rs.StartTime).Seconds()), SecondsSinceStartTime: int(time.Now().Sub(rs.StartTime).Seconds()),
LastCommitRound: rs.LastCommit.Round(), LastCommitRound: rs.LastCommit.Round(),
} }
if step == RoundStepCommit {
if rs.Step == RoundStepCommit {
csMsg = &CommitStepMessage{ csMsg = &CommitStepMessage{
Height: rs.Height, Height: rs.Height,
BlockPartsHeader: rs.ProposalBlockParts.Header(), BlockPartsHeader: rs.ProposalBlockParts.Header(),


+ 8
- 3
consensus/state.go View File

@ -316,6 +316,7 @@ func (cs *ConsensusState) AddProposalBlockPart(height, round int, part *types.Pa
return nil return nil
} }
// May block on send if queue is full.
func (cs *ConsensusState) SetProposalAndBlock(proposal *types.Proposal, block *types.Block, parts *types.PartSet, peerKey string) error { func (cs *ConsensusState) SetProposalAndBlock(proposal *types.Proposal, block *types.Block, parts *types.PartSet, peerKey string) error {
cs.SetProposal(proposal, peerKey) cs.SetProposal(proposal, peerKey)
for i := 0; i < parts.Total(); i++ { for i := 0; i < parts.Total(); i++ {
@ -341,6 +342,9 @@ func (cs *ConsensusState) updateRoundStep(round int, step RoundStepType) {
func (cs *ConsensusState) scheduleRound0(height int) { func (cs *ConsensusState) scheduleRound0(height int) {
//log.Info("scheduleRound0", "now", time.Now(), "startTime", cs.StartTime) //log.Info("scheduleRound0", "now", time.Now(), "startTime", cs.StartTime)
sleepDuration := cs.StartTime.Sub(time.Now()) sleepDuration := cs.StartTime.Sub(time.Now())
if sleepDuration < time.Duration(0) {
sleepDuration = time.Duration(0)
}
cs.scheduleTimeout(sleepDuration, height, 0, RoundStepNewHeight) cs.scheduleTimeout(sleepDuration, height, 0, RoundStepNewHeight)
} }
@ -749,7 +753,7 @@ func (cs *ConsensusState) decideProposal(height, round int) {
part := blockParts.GetPart(i) part := blockParts.GetPart(i)
cs.sendInternalMessage(msgInfo{&BlockPartMessage{cs.Height, cs.Round, part}, ""}) cs.sendInternalMessage(msgInfo{&BlockPartMessage{cs.Height, cs.Round, part}, ""})
} }
log.Notice("Signed and sent proposal", "height", height, "round", round, "proposal", proposal)
log.Info("Signed and sent proposal", "height", height, "round", round, "proposal", proposal)
log.Debug(Fmt("Signed and sent proposal block: %v", block)) log.Debug(Fmt("Signed and sent proposal block: %v", block))
} else { } else {
log.Warn("enterPropose: Error signing proposal", "height", height, "round", round, "error", err) log.Warn("enterPropose: Error signing proposal", "height", height, "round", round, "error", err)
@ -1130,7 +1134,8 @@ func (cs *ConsensusState) finalizeCommit(height int) {
PanicConsensus(Fmt("+2/3 committed an invalid block: %v", err)) PanicConsensus(Fmt("+2/3 committed an invalid block: %v", err))
} }
log.Info(Fmt("Finalizing commit of block: %v", cs.ProposalBlock))
log.Notice("Finalizing commit of block", "height", cs.ProposalBlock.Height, "hash", cs.ProposalBlock.Hash())
log.Info(Fmt("%v", cs.ProposalBlock))
// We have the block, so stage/save/commit-vote. // We have the block, so stage/save/commit-vote.
cs.saveBlock(cs.ProposalBlock, cs.ProposalBlockParts, cs.Votes.Precommits(cs.CommitRound)) cs.saveBlock(cs.ProposalBlock, cs.ProposalBlockParts, cs.Votes.Precommits(cs.CommitRound))
@ -1402,7 +1407,7 @@ func (cs *ConsensusState) signAddVote(type_ byte, hash []byte, header types.Part
// TODO: store our index in the cs so we don't have to do this every time // TODO: store our index in the cs so we don't have to do this every time
valIndex, _ := cs.Validators.GetByAddress(cs.privValidator.Address) valIndex, _ := cs.Validators.GetByAddress(cs.privValidator.Address)
cs.sendInternalMessage(msgInfo{&VoteMessage{valIndex, vote}, ""}) cs.sendInternalMessage(msgInfo{&VoteMessage{valIndex, vote}, ""})
log.Notice("Signed and pushed vote", "height", cs.Height, "round", cs.Round, "vote", vote, "error", err)
log.Info("Signed and pushed vote", "height", cs.Height, "round", cs.Round, "vote", vote, "error", err)
return vote return vote
} else { } else {
log.Warn("Error signing vote", "height", cs.Height, "round", cs.Round, "vote", vote, "error", err) log.Warn("Error signing vote", "height", cs.Height, "round", cs.Round, "vote", vote, "error", err)


Loading…
Cancel
Save