dummy: valset changes and tests

This commit is contained in:
Ethan Buchman
2016-11-21 23:42:42 -05:00
parent 9a2d3e51ed
commit b200b82418
6 changed files with 378 additions and 16 deletions

24
types/validators.go Normal file
View File

@ -0,0 +1,24 @@
package types
import (
"bytes"
)
// validators implements sort
type Validators []*Validator
func (v Validators) Len() int {
return len(v)
}
// XXX: doesn't distinguish same validator with different power
func (v Validators) Less(i, j int) bool {
return bytes.Compare(v[i].PubKey, v[j].PubKey) <= 0
}
func (v Validators) Swap(i, j int) {
v1 := v[i]
v[i] = v[j]
v[j] = v1
}