-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtypes.go
More file actions
100 lines (83 loc) · 2 KB
/
types.go
File metadata and controls
100 lines (83 loc) · 2 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
package seiconfig
import (
"fmt"
"time"
)
// NodeMode represents the operating mode of a Sei node.
type NodeMode string
const (
ModeValidator NodeMode = "validator"
ModeFull NodeMode = "full"
ModeSeed NodeMode = "seed"
ModeArchive NodeMode = "archive"
)
var validModes = map[NodeMode]bool{
ModeValidator: true,
ModeFull: true,
ModeSeed: true,
ModeArchive: true,
}
func (m NodeMode) IsValid() bool {
return validModes[m]
}
func (m NodeMode) IsFullnodeType() bool {
switch m {
case ModeFull, ModeArchive:
return true
default:
return false
}
}
func (m NodeMode) String() string {
return string(m)
}
// Duration wraps time.Duration for human-readable TOML serialization.
// Values are encoded as Go duration strings (e.g. "10s", "100ms", "168h").
type Duration struct {
time.Duration
}
func (d Duration) MarshalText() ([]byte, error) {
return []byte(d.String()), nil
}
func (d *Duration) UnmarshalText(text []byte) error {
dur, err := time.ParseDuration(string(text))
if err != nil {
return fmt.Errorf("invalid duration %q: %w", string(text), err)
}
d.Duration = dur
return nil
}
func Dur(d time.Duration) Duration {
return Duration{Duration: d}
}
// WriteMode controls how EVM data writes are routed between backends.
type WriteMode string
const (
WriteModeCosmosOnly WriteMode = "cosmos_only"
WriteModeDualWrite WriteMode = "dual_write"
WriteModeSplitWrite WriteMode = "split_write"
WriteModeEVMOnly WriteMode = "evm_only"
)
func (m WriteMode) IsValid() bool {
switch m {
case WriteModeCosmosOnly, WriteModeDualWrite, WriteModeSplitWrite, WriteModeEVMOnly:
return true
default:
return false
}
}
// ReadMode controls how EVM data reads are routed.
type ReadMode string
const (
ReadModeCosmosOnly ReadMode = "cosmos_only"
ReadModeEVMFirst ReadMode = "evm_first"
ReadModeSplitRead ReadMode = "split_read"
)
func (m ReadMode) IsValid() bool {
switch m {
case ReadModeCosmosOnly, ReadModeEVMFirst, ReadModeSplitRead:
return true
default:
return false
}
}