diff --git a/types/config.go b/types/config.go index dba8714a..1c552e36 100644 --- a/types/config.go +++ b/types/config.go @@ -97,7 +97,7 @@ type Config struct { Endpoint string `yaml:"endpoint" envconfig:"BEACONAPI_ENDPOINT"` Endpoints []EndpointConfig `yaml:"endpoints"` EndpointsURL string `yaml:"endpointsUrl" envconfig:"BEACONAPI_ENDPOINTS_URL"` - ClientIndex int `yaml:"clientIndex" envconfig:"BEACONAPI_CLIENT_INDEX"` + ClientIndex *int `yaml:"clientIndex" envconfig:"BEACONAPI_CLIENT_INDEX"` LocalCacheSize int `yaml:"localCacheSize" envconfig:"BEACONAPI_LOCAL_CACHE_SIZE"` SkipFinalAssignments bool `yaml:"skipFinalAssignments" envconfig:"BEACONAPI_SKIP_FINAL_ASSIGNMENTS"` diff --git a/utils/config.go b/utils/config.go index e8396e8c..31e1ddd3 100644 --- a/utils/config.go +++ b/utils/config.go @@ -46,9 +46,9 @@ func ReadConfig(cfg *types.Config, path string) error { } } - // ClientIndex selects a specific endpoint by index (0-based) - if cfg.BeaconApi.ClientIndex >= 0 && cfg.BeaconApi.ClientIndex < len(cfg.BeaconApi.Endpoints) { - selectedEndpoint := cfg.BeaconApi.Endpoints[cfg.BeaconApi.ClientIndex] + // ClientIndex selects a specific endpoint by index (0-based), when explicitly set + if cfg.BeaconApi.ClientIndex != nil && *cfg.BeaconApi.ClientIndex >= 0 && *cfg.BeaconApi.ClientIndex < len(cfg.BeaconApi.Endpoints) { + selectedEndpoint := cfg.BeaconApi.Endpoints[*cfg.BeaconApi.ClientIndex] cfg.BeaconApi.Endpoints = []types.EndpointConfig{selectedEndpoint} }