diff --git a/config/config.go b/config/config.go index 83fadef7c..b7253f09c 100644 --- a/config/config.go +++ b/config/config.go @@ -156,7 +156,13 @@ type NodesConfig struct { // MinercraftCustomAPIs is a slice of Minercraft custom miners APIs. MinercraftCustomAPIs []*minercraft.MinerAPIs `json:"minercraft_custom_apis" mapstructure:"minercraft_custom_apis"` // BroadcastClientAPIs is a slice of Broadcast Client custom miners APIs. - BroadcastClientAPIs []string `json:"broadcast_client_apis" mapstructure:"broadcast_client_apis"` + BroadcastClientAPIs []*BroadcastClientAPI `json:"broadcast_client_apis" mapstructure:"broadcast_client_apis"` +} + +// BroadcastClientAPI is a URL-Token pair for Broadcast Client; Token is optional +type BroadcastClientAPI struct { + Token string `json:"token,omitempty"` + URL string `json:"url,omitempty"` } // NotificationsConfig is the configuration for notifications diff --git a/config/defaults.go b/config/defaults.go index dc3289bc8..b4e0bee0a 100644 --- a/config/defaults.go +++ b/config/defaults.go @@ -119,7 +119,7 @@ func getNodesDefaults() *NodesConfig { UseMapiFeeQuotes: true, MinercraftAPI: "mAPI", MinercraftCustomAPIs: []*minercraft.MinerAPIs{}, - BroadcastClientAPIs: []string{}, + BroadcastClientAPIs: []*BroadcastClientAPI{}, } } diff --git a/config/services.go b/config/services.go index 08b903e74..c0ca4d60b 100644 --- a/config/services.go +++ b/config/services.go @@ -366,28 +366,6 @@ func loadDatastore(options []bux.ClientOps, appConfig *AppConfig, testMode bool) return options, nil } -// splitBroadcastClientApis splits the broadcast client apis into a list of broadcast_client.ArcClientConfig -func splitBroadcastClientApis(apis []string) []broadcastclient.ArcClientConfig { - var arcClients []broadcastclient.ArcClientConfig - for _, api := range apis { - separatorIndex := strings.Index(api, "|") - if separatorIndex != -1 { - apiURL := api[:separatorIndex] - token := api[separatorIndex+1:] - - arcClients = append(arcClients, broadcastclient.ArcClientConfig{ - APIUrl: apiURL, - Token: token, - }) - } else { - arcClients = append(arcClients, broadcastclient.ArcClientConfig{ - APIUrl: api, - }) - } - } - return arcClients -} - func loadTaskManager(appConfig *AppConfig, options []bux.ClientOps) []bux.ClientOps { ops := []taskmanager.TasqOps{} if appConfig.TaskManager.Factory == taskmanager.FactoryRedis { @@ -401,11 +379,13 @@ func loadTaskManager(appConfig *AppConfig, options []bux.ClientOps) []bux.Client func loadBroadcastClientAPI(appConfig *AppConfig, options []bux.ClientOps) []bux.ClientOps { if appConfig.Nodes.BroadcastClientAPIs != nil { - arcClientConfigs := splitBroadcastClientApis(appConfig.Nodes.BroadcastClientAPIs) builder := broadcastclient.Builder() - for _, cfg := range arcClientConfigs { - builder.WithArc(cfg) + for _, cfg := range appConfig.Nodes.BroadcastClientAPIs { + builder.WithArc(broadcastclient.ArcClientConfig{ + Token: cfg.Token, + APIUrl: cfg.URL, + }) } broadcastClient := builder.Build() options = append(options, bux.WithBroadcastClient(broadcastClient))