7 "github.com/tendermint/go-wire/data"
8 cmn "github.com/tendermint/tmlibs/common"
11 // validators implements sort
13 type Validators []*Validator
15 func (v Validators) Len() int {
19 // XXX: doesn't distinguish same validator with different power
20 func (v Validators) Less(i, j int) bool {
21 return bytes.Compare(v[i].PubKey, v[j].PubKey) <= 0
24 func (v Validators) Swap(i, j int) {
30 //-------------------------------------
32 type validatorPretty struct {
33 PubKey data.Bytes `json:"pub_key"`
34 Power uint64 `json:"power"`
37 func ValidatorsString(vs Validators) string {
38 s := make([]validatorPretty, len(vs))
39 for i, v := range vs {
40 s[i] = validatorPretty{v.PubKey, v.Power}
42 b, err := json.Marshal(s)
44 cmn.PanicSanity(err.Error())