Browse Source

types: pretty print validators

pull/1780/head
Ethan Buchman 8 years ago
parent
commit
2dce41ad6a
1 changed files with 17 additions and 0 deletions
  1. +17
    -0
      types/validators.go

+ 17
- 0
types/validators.go View File

@ -2,6 +2,8 @@ package types
import (
"bytes"
"github.com/tendermint/go-wire"
)
// validators implements sort
@ -22,3 +24,18 @@ func (v Validators) Swap(i, j int) {
v[i] = v[j]
v[j] = v1
}
//-------------------------------------
type validatorPretty struct {
PubKey []byte `json:"pub_key"`
Power uint64 `json:"power"`
}
func ValidatorsString(vs Validators) string {
s := make([]validatorPretty, len(vs))
for i, v := range vs {
s[i] = validatorPretty{v.PubKey, v.Power}
}
return string(wire.JSONBytes(s))
}

Loading…
Cancel
Save