mirror of
https://github.com/tendermint/tendermint.git
synced 2026-09-19 22:44:24 +00:00
pretty print ConsensusState
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package state
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
. "github.com/tendermint/tendermint/binary"
|
||||
@@ -73,6 +74,10 @@ func (v *Validator) CompareAccum(other *Validator) *Validator {
|
||||
}
|
||||
}
|
||||
|
||||
func (v *Validator) String() string {
|
||||
return fmt.Sprintf("Validator{%v VP:%v A:%v}", v.Account, v.VotingPower, v.Accum)
|
||||
}
|
||||
|
||||
//-------------------------------------
|
||||
|
||||
var ValidatorCodec = validatorCodec{}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package state
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"strings"
|
||||
|
||||
. "github.com/tendermint/tendermint/binary"
|
||||
"github.com/tendermint/tendermint/merkle"
|
||||
@@ -124,3 +126,21 @@ func (vset *ValidatorSet) Iterate(fn func(val *Validator) bool) {
|
||||
return fn(val_.(*Validator))
|
||||
})
|
||||
}
|
||||
|
||||
func (vset *ValidatorSet) StringWithIndent(indent string) string {
|
||||
valStrings := []string{}
|
||||
vset.Iterate(func(val *Validator) bool {
|
||||
valStrings = append(valStrings, val.String())
|
||||
return false
|
||||
})
|
||||
return fmt.Sprintf(`ValidatorSet{
|
||||
%s Proposer: %v
|
||||
%s Validators:
|
||||
%s %v
|
||||
%s}`,
|
||||
indent, vset.proposer.String(),
|
||||
indent,
|
||||
indent, strings.Join(valStrings, "\n"+indent+" "),
|
||||
indent)
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user