-
Notifications
You must be signed in to change notification settings - Fork 922
/
type.go
59 lines (50 loc) · 1.44 KB
/
type.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
54
55
56
57
58
59
package node
// Type defines the Node type (e.g. `light`, `bridge`) for identity purposes.
// The zero value for Type is invalid.
type Type uint8
// StorePath is an alias used in order to pass the base path of the node store to nodebuilder
// modules.
type StorePath string
const (
// Bridge is a Celestia Node that bridges the Celestia consensus network and data availability
// network. It maintains a trusted channel/connection to a Celestia Core node via the core.Client
// API.
Bridge Type = iota + 1
// Light is a stripped-down Celestia Node which aims to be lightweight while preserving the highest
// possible security guarantees.
Light
// Full is a Celestia Node that stores blocks in their entirety.
Full
)
// String converts Type to its string representation.
func (t Type) String() string {
if !t.IsValid() {
return "unknown"
}
return typeToString[t]
}
// IsValid reports whether the Type is valid.
func (t Type) IsValid() bool {
_, ok := typeToString[t]
return ok
}
// ParseType converts string in a type if possible.
func ParseType(str string) Type {
tp, ok := stringToType[str]
if !ok {
return 0
}
return tp
}
// typeToString keeps string representations of all valid Types.
var typeToString = map[Type]string{
Bridge: "Bridge",
Light: "Light",
Full: "Full",
}
// typeToString maps strings representations of all valid Types.
var stringToType = map[string]Type{
"Bridge": Bridge,
"Light": Light,
"Full": Full,
}