Browse Source

more debug messages for consensus

pull/67/head
Jae Kwon 9 years ago
parent
commit
84c3fd9a85
3 changed files with 24 additions and 9 deletions
  1. +2
    -3
      cmd/debora/main.go
  2. +20
    -4
      consensus/state.go
  3. +2
    -2
      consensus/vote_set.go

+ 2
- 3
cmd/debora/main.go View File

@ -241,16 +241,15 @@ func cliDownloadFile(c *cli.Context) {
wg := sync.WaitGroup{}
for i, remote := range Config.Remotes {
wg.Add(1)
go func(remote string) {
go func(remote string, localPath string) {
defer wg.Done()
localPath := Fmt("%v_%v", localPathPrefix, i)
n, err := DownloadFile(Config.PrivKey, remote, command, localPath)
if err != nil {
fmt.Printf("%v failure. %v\n", remote, err)
} else {
fmt.Printf("%v success. Wrote %v bytes to %v\n", remote, n, localPath)
}
}(remote)
}(remote, Fmt("%v_%v", localPathPrefix, i))
}
wg.Wait()
}

+ 20
- 4
consensus/state.go View File

@ -1025,10 +1025,18 @@ func (cs *ConsensusState) addVote(address []byte, vote *types.Vote) (added bool,
switch vote.Type {
case types.VoteTypePrevote:
// Prevotes checks for height+round match.
return cs.Prevotes.Add(address, vote)
added, index, err = cs.Prevotes.Add(address, vote)
if added {
log.Debug(Fmt("Added prevote: %v", cs.Prevotes.StringShort()))
}
return
case types.VoteTypePrecommit:
// Precommits checks for height+round match.
return cs.Precommits.Add(address, vote)
added, index, err = cs.Precommits.Add(address, vote)
if added {
log.Debug(Fmt("Added precommit: %v", cs.Precommits.StringShort()))
}
return
case types.VoteTypeCommit:
if vote.Height == cs.Height {
// No need to check if vote.Round < cs.Round ...
@ -1045,10 +1053,18 @@ func (cs *ConsensusState) addVote(address []byte, vote *types.Vote) (added bool,
cs.queueAction(RoundAction{cs.Height, cs.Round, RoundActionTryFinalize})
}
}
return added, index, err
if added {
log.Debug(Fmt("Added commit: %v\nprecommits: %v\nprevotes: %v",
cs.Commits.StringShort(),
cs.Precommits.StringShort(),
cs.Prevotes.StringShort()))
}
return
}
if vote.Height+1 == cs.Height {
return cs.LastCommits.Add(address, vote)
added, index, err = cs.LastCommits.Add(address, vote)
log.Debug(Fmt("Added lastCommits: %v", cs.LastCommits.StringShort()))
return
}
return false, 0, nil
default:


+ 2
- 2
consensus/vote_set.go View File

@ -287,6 +287,6 @@ func (voteSet *VoteSet) StringShort() string {
}
voteSet.mtx.Lock()
defer voteSet.mtx.Unlock()
return fmt.Sprintf(`VoteSet{H:%v R:%v T:%v %v}`,
voteSet.height, voteSet.round, voteSet.type_, voteSet.votesBitArray)
return fmt.Sprintf(`VoteSet{H:%v R:%v T:%v +2/3:%v %v}`,
voteSet.height, voteSet.round, voteSet.type_, voteSet.maj23Exists, voteSet.votesBitArray)
}

Loading…
Cancel
Save