You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
810 B

  1. package types
  2. import (
  3. "sort"
  4. )
  5. //------------------------------------------------------------------------------
  6. // ValidatorUpdates is a list of validators that implements the Sort interface
  7. type ValidatorUpdates []ValidatorUpdate
  8. var _ sort.Interface = (ValidatorUpdates)(nil)
  9. // All these methods for ValidatorUpdates:
  10. // Len, Less and Swap
  11. // are for ValidatorUpdates to implement sort.Interface
  12. // which will be used by the sort package.
  13. // See Issue https://github.com/tendermint/abci/issues/212
  14. func (v ValidatorUpdates) Len() int {
  15. return len(v)
  16. }
  17. // XXX: doesn't distinguish same validator with different power
  18. func (v ValidatorUpdates) Less(i, j int) bool {
  19. return v[i].PubKey.Compare(v[j].PubKey) <= 0
  20. }
  21. func (v ValidatorUpdates) Swap(i, j int) {
  22. v1 := v[i]
  23. v[i] = v[j]
  24. v[j] = v1
  25. }