fix dump_consensus_state error'ing when height=0

This commit is contained in:
Jae Kwon
2015-07-10 09:55:23 -07:00
committed by Ethan Buchman
parent 72b681a1bc
commit 41845d5b85
2 changed files with 10 additions and 0 deletions

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,

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())