@@ -21,13 +21,16 @@ const (
2121 Light NodeType = "light"
2222 // Observability represents a observability monitoring node for Prometheus/Grafana.
2323 Observability NodeType = "observability"
24+ // Encoder represents a dedicated fibre-txsim encoder node.
25+ Encoder NodeType = "encoder"
2426)
2527
2628var (
2729 valCount = atomic.Uint32 {}
2830 nodeCount = atomic.Uint32 {}
2931 lightCount = atomic.Uint32 {}
3032 observabilityCount = atomic.Uint32 {}
33+ encoderCount = atomic.Uint32 {}
3134)
3235
3336// NodeName returns the name of the node based on its type and index. The
@@ -44,6 +47,8 @@ func NodeName(nodeType NodeType) string {
4447 index = int (lightCount .Add (1 )) - 1
4548 case Observability :
4649 index = int (observabilityCount .Add (1 )) - 1
50+ case Encoder :
51+ index = int (encoderCount .Add (1 )) - 1
4752 default :
4853 panic (fmt .Sprintf ("unknown node type: %s" , nodeType ))
4954 }
@@ -120,7 +125,7 @@ func ExperimentTag(nodeType NodeType, index int, experimentID, chainID string) s
120125
121126func GetExperimentTag (tags []string ) string {
122127 for _ , tag := range tags {
123- if strings .HasPrefix (tag , "validator-" ) || strings .HasPrefix (tag , "bridge-" ) || strings .HasPrefix (tag , "light-" ) || strings .HasPrefix (tag , "observability-" ) {
128+ if strings .HasPrefix (tag , "validator-" ) || strings .HasPrefix (tag , "bridge-" ) || strings .HasPrefix (tag , "light-" ) || strings .HasPrefix (tag , "observability-" ) || strings . HasPrefix ( tag , "encoder-" ) {
124129 return tag
125130 }
126131 }
@@ -133,6 +138,7 @@ type Config struct {
133138 Bridges []Instance `json:"bridges,omitempty"`
134139 Lights []Instance `json:"lights,omitempty"`
135140 Observability []Instance `json:"observability,omitempty"`
141+ Encoders []Instance `json:"encoders,omitempty"`
136142
137143 // ChainID is the chain ID of the network. This is used to identify the
138144 // network and is also used as the chain ID of the network. It is
@@ -164,6 +170,7 @@ func NewConfig(experiment, chainID string) Config {
164170 Bridges : []Instance {},
165171 Lights : []Instance {},
166172 Observability : []Instance {},
173+ Encoders : []Instance {},
167174 Experiment : experiment ,
168175 ChainID : TalisChainID (chainID ),
169176 S3Config : S3Config {
@@ -230,6 +237,18 @@ func (cfg Config) WithGoogleCloudObservability(region string) Config {
230237 return cfg
231238}
232239
240+ func (cfg Config ) WithDigitalOceanEncoder (region string ) Config {
241+ i := NewDigitalOceanEncoder (region ).WithExperiment (cfg .Experiment , cfg .ChainID )
242+ cfg .Encoders = append (cfg .Encoders , i )
243+ return cfg
244+ }
245+
246+ func (cfg Config ) WithGoogleCloudEncoder (region string ) Config {
247+ i := NewGoogleCloudEncoder (region ).WithExperiment (cfg .Experiment , cfg .ChainID )
248+ cfg .Encoders = append (cfg .Encoders , i )
249+ return cfg
250+ }
251+
233252func (cfg Config ) WithChainID (chainID string ) Config {
234253 cfg .ChainID = TalisChainID (chainID )
235254 return cfg
@@ -306,5 +325,12 @@ func (cfg Config) UpdateInstance(name, publicIP, privateIP string) (Config, erro
306325 return cfg , nil
307326 }
308327 }
328+ for i := range cfg .Encoders {
329+ if cfg .Encoders [i ].Name == name {
330+ cfg .Encoders [i ].PublicIP = publicIP
331+ cfg .Encoders [i ].PrivateIP = privateIP
332+ return cfg , nil
333+ }
334+ }
309335 return cfg , fmt .Errorf ("instance %s not found" , name )
310336}
0 commit comments