-
Notifications
You must be signed in to change notification settings - Fork 7
/
options.go
53 lines (41 loc) · 987 Bytes
/
options.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package types
import (
"fmt"
querytypes "github.com/KYVENetwork/chain/x/query/types"
)
var (
CacheOptionJsonFile = NewStringOption("jsonfile")
CacheOptionMemory = NewStringOption("memory")
)
type StringOption struct {
Option[string]
value string
}
func NewStringOption(value string) StringOption {
return StringOption{value: value}
}
func (o StringOption) Name() string {
return o.value
}
func (o StringOption) Value() string {
return o.value
}
func (o StringOption) StringValue() string {
return o.value
}
type PoolOption struct {
Option[uint64]
value querytypes.PoolResponse
}
func NewPoolOption(pool querytypes.PoolResponse) PoolOption {
return PoolOption{value: pool}
}
func (o PoolOption) Name() string {
return fmt.Sprintf("%s (%d)", o.value.GetData().GetName(), o.value.GetData().GetId())
}
func (o PoolOption) Value() uint64 {
return o.value.GetId()
}
func (o PoolOption) StringValue() string {
return fmt.Sprintf("%d", o.value.GetData().GetId())
}