github.com/celestiaorg/celestia-node@v0.15.0-beta.1/nodebuilder/node/type.go (about) 1 package node 2 3 // Type defines the Node type (e.g. `light`, `bridge`) for identity purposes. 4 // The zero value for Type is invalid. 5 type Type uint8 6 7 // StorePath is an alias used in order to pass the base path of the node store to nodebuilder 8 // modules. 9 type StorePath string 10 11 const ( 12 // Bridge is a Celestia Node that bridges the Celestia consensus network and data availability 13 // network. It maintains a trusted channel/connection to a Celestia Core node via the core.Client 14 // API. 15 Bridge Type = iota + 1 16 // Light is a stripped-down Celestia Node which aims to be lightweight while preserving the highest 17 // possible security guarantees. 18 Light 19 // Full is a Celestia Node that stores blocks in their entirety. 20 Full 21 ) 22 23 // String converts Type to its string representation. 24 func (t Type) String() string { 25 if !t.IsValid() { 26 return "unknown" 27 } 28 return typeToString[t] 29 } 30 31 // IsValid reports whether the Type is valid. 32 func (t Type) IsValid() bool { 33 _, ok := typeToString[t] 34 return ok 35 } 36 37 // ParseType converts string in a type if possible. 38 func ParseType(str string) Type { 39 tp, ok := stringToType[str] 40 if !ok { 41 return 0 42 } 43 44 return tp 45 } 46 47 // typeToString keeps string representations of all valid Types. 48 var typeToString = map[Type]string{ 49 Bridge: "Bridge", 50 Light: "Light", 51 Full: "Full", 52 } 53 54 // typeToString maps strings representations of all valid Types. 55 var stringToType = map[string]Type{ 56 "Bridge": Bridge, 57 "Light": Light, 58 "Full": Full, 59 }