Browse Source

fix dump_consensus_state error'ing when height=0

pull/108/merge
Jae Kwon 9 years ago
committed by Ethan Buchman
parent
commit
41845d5b85
2 changed files with 10 additions and 0 deletions
  1. +4
    -0
      state/validator.go
  2. +6
    -0
      state/validator_set.go

+ 4
- 0
state/validator.go View File

@ -56,6 +56,7 @@ type Validator struct {
}
// Creates a new copy of the validator so we can mutate accum.
// Panics if the validator is nil.
func (v *Validator) Copy() *Validator {
vCopy := *v
return &vCopy
@ -83,6 +84,9 @@ func (v *Validator) CompareAccum(other *Validator) *Validator {
}
func (v *Validator) String() string {
if v == nil {
return "nil-Validator"
}
return fmt.Sprintf("Validator{%X %v %v-%v-%v VP:%v A:%v}",
v.Address,
v.PubKey,


+ 6
- 0
state/validator_set.go View File

@ -112,6 +112,9 @@ func (valSet *ValidatorSet) TotalVotingPower() int64 {
}
func (valSet *ValidatorSet) Proposer() (proposer *Validator) {
if len(valSet.Validators) == 0 {
return nil
}
if valSet.proposer == nil {
for _, val := range valSet.Validators {
valSet.proposer = valSet.proposer.CompareAccum(val)
@ -255,6 +258,9 @@ func (valSet *ValidatorSet) String() string {
}
func (valSet *ValidatorSet) StringIndented(indent string) string {
if valSet == nil {
return "nil-ValidatorSet"
}
valStrings := []string{}
valSet.Iterate(func(index int, val *Validator) bool {
valStrings = append(valStrings, val.String())


Loading…
Cancel
Save