1
1
package types
2
2
3
3
import (
4
- "bytes"
5
- "sort"
6
- "strings"
7
-
8
- "cosmossdk.io/core/address"
9
4
"cosmossdk.io/math"
10
5
11
6
"github.com/cosmos/cosmos-sdk/codec"
@@ -19,49 +14,6 @@ func NewLiquidValidator(operator string) LiquidValidator {
19
14
}
20
15
}
21
16
22
- // LiquidValidators is a collection of LiquidValidator
23
- type LiquidValidators struct {
24
- LiquidValidators []LiquidValidator
25
- ValidatorCodec address.Codec
26
- }
27
-
28
- func (v LiquidValidators ) String () (out string ) {
29
- for _ , val := range v .LiquidValidators {
30
- out += val .String () + "\n "
31
- }
32
-
33
- return strings .TrimSpace (out )
34
- }
35
-
36
- // Sort Validators sorts validator array in ascending operator address order
37
- func (v LiquidValidators ) Sort () {
38
- sort .Sort (v )
39
- }
40
-
41
- // Len implements sort interface
42
- func (v LiquidValidators ) Len () int {
43
- return len (v .LiquidValidators )
44
- }
45
-
46
- // Less implements sort interface
47
- func (v LiquidValidators ) Less (i , j int ) bool {
48
- vi , err := v .ValidatorCodec .StringToBytes (v .LiquidValidators [i ].OperatorAddress )
49
- if err != nil {
50
- panic (err )
51
- }
52
- vj , err := v .ValidatorCodec .StringToBytes (v .LiquidValidators [j ].OperatorAddress )
53
- if err != nil {
54
- panic (err )
55
- }
56
-
57
- return bytes .Compare (vi , vj ) == - 1
58
- }
59
-
60
- // Swap implements sort interface
61
- func (v LiquidValidators ) Swap (i , j int ) {
62
- v .LiquidValidators [i ], v .LiquidValidators [j ] = v .LiquidValidators [j ], v .LiquidValidators [i ]
63
- }
64
-
65
17
func MustMarshalValidator (cdc codec.BinaryCodec , validator * LiquidValidator ) []byte {
66
18
return cdc .MustMarshal (validator )
67
19
}
0 commit comments