@@ -26,19 +26,7 @@ var StartCommand = &cli.Command{
2626 Action : operatorMain ,
2727}
2828
29- func operatorMain (ctx * cli.Context ) error {
30- operatorConfigFilePath := ctx .String ("config" )
31- operatorConfig := config .NewOperatorConfig (operatorConfigFilePath )
32- err := sdkutils .ReadYamlConfig (operatorConfigFilePath , & operatorConfig )
33- if err != nil {
34- return err
35- }
36-
37- operator , err := operator .NewOperatorFromConfig (* operatorConfig )
38- if err != nil {
39- return err
40- }
41-
29+ func updateTelemetryService (operator * operator.Operator , ctx * cli.Context , operatorConfig * config.OperatorConfig ) error {
4230 // hash version
4331 hash := sha3 .NewLegacyKeccak256 ()
4432 hash .Write ([]byte (ctx .App .Version ))
@@ -51,11 +39,32 @@ func operatorMain(ctx *cli.Context) error {
5139 if err != nil {
5240 return err
5341 }
42+ ethRpcUrl , err := baseUrlOnly (operatorConfig .BaseConfig .EthRpcUrl )
43+ if err != nil {
44+ return err
45+ }
46+ ethRpcUrlFallback , err := baseUrlOnly (operatorConfig .BaseConfig .EthRpcUrlFallback )
47+ if err != nil {
48+ return err
49+ }
50+ ethWsUrl , err := baseUrlOnly (operatorConfig .BaseConfig .EthWsUrl )
51+ if err != nil {
52+ return err
53+ }
54+ ethWsUrlFallback , err := baseUrlOnly (operatorConfig .BaseConfig .EthWsUrlFallback )
55+ if err != nil {
56+ return err
57+ }
5458
5559 body := map [string ]interface {}{
56- "version" : ctx .App .Version ,
57- "signature" : signature ,
60+ "version" : ctx .App .Version ,
61+ "signature" : signature ,
62+ "eth_rpc_url" : ethRpcUrl ,
63+ "eth_rpc_url_fallback" : ethRpcUrlFallback ,
64+ "eth_ws_url" : ethWsUrl ,
65+ "eth_ws_url_fallback" : ethWsUrlFallback ,
5866 }
67+
5968 bodyBuffer := new (bytes.Buffer )
6069
6170 bodyReader := json .NewEncoder (bodyBuffer )
@@ -68,15 +77,35 @@ func operatorMain(ctx *cli.Context) error {
6877 endpoint := operatorConfig .Operator .OperatorTrackerIpPortAddress + "/versions"
6978 operator .Logger .Info ("Sending version to operator tracker server: " , "endpoint" , endpoint )
7079
71- res , err := http .Post (endpoint , "application/json" ,
72- bodyBuffer )
80+ res , err := http .Post (endpoint , "application/json" , bodyBuffer )
7381 if err != nil {
7482 // Dont prevent operator from starting if operator tracker server is down
7583 operator .Logger .Warn ("Error sending version to metrics server: " , "err" , err )
7684 } else if res .StatusCode != http .StatusCreated && res .StatusCode != http .StatusNoContent {
7785 operator .Logger .Warn ("Error sending version to operator tracker server: " , "status_code" , res .StatusCode )
7886 }
7987
88+ return nil
89+ }
90+
91+ func operatorMain (ctx * cli.Context ) error {
92+ operatorConfigFilePath := ctx .String ("config" )
93+ operatorConfig := config .NewOperatorConfig (operatorConfigFilePath )
94+ err := sdkutils .ReadYamlConfig (operatorConfigFilePath , & operatorConfig )
95+ if err != nil {
96+ return err
97+ }
98+
99+ operator , err := operator .NewOperatorFromConfig (* operatorConfig )
100+ if err != nil {
101+ return err
102+ }
103+
104+ err = updateTelemetryService (operator , ctx , operatorConfig )
105+ if err != nil {
106+ return err
107+ }
108+
80109 operator .Logger .Info ("Operator starting..." )
81110 err = operator .Start (context .Background ())
82111 if err != nil {
0 commit comments