@@ -36,6 +36,8 @@ pub struct Config {
3636 pub proposer_nodes : Vec < SensitiveUrl > ,
3737 /// The http endpoints of the execution node APIs.
3838 pub execution_nodes : Vec < SensitiveUrl > ,
39+ /// The websocket endpoints of the execution node APIs.
40+ pub execution_nodes_websocket : Vec < SensitiveUrl > ,
3941 /// beacon node is not synced at startup.
4042 pub allow_unsynced_beacon_node : bool ,
4143 /// If true, use longer timeouts for requests made to the beacon node.
@@ -79,19 +81,18 @@ impl Config {
7981
8082 let beacon_nodes = vec ! [ SensitiveUrl :: parse( DEFAULT_BEACON_NODE )
8183 . expect( "beacon_nodes must always be a valid url." ) ] ;
82- let execution_nodes = vec ! [
83- SensitiveUrl :: parse( DEFAULT_EXECUTION_NODE )
84- . expect( "execution_nodes must always be a valid url." ) ,
85- SensitiveUrl :: parse( DEFAULT_EXECUTION_NODE_WS )
86- . expect( "execution_nodes must always be a valid url." ) ,
87- ] ;
84+ let execution_nodes = vec ! [ SensitiveUrl :: parse( DEFAULT_EXECUTION_NODE )
85+ . expect( "execution_nodes must always be a valid url." ) ] ;
86+ let execution_nodes_websocket = vec ! [ SensitiveUrl :: parse( DEFAULT_EXECUTION_NODE_WS )
87+ . expect( "execution_nodes_websocket must always be a valid url." ) ] ;
8888
8989 Self {
9090 data_dir,
9191 ssv_network,
9292 beacon_nodes,
9393 proposer_nodes : vec ! [ ] ,
9494 execution_nodes,
95+ execution_nodes_websocket,
9596 allow_unsynced_beacon_node : false ,
9697 use_long_timeouts : false ,
9798 http_api : <_ >:: default ( ) ,
@@ -127,20 +128,18 @@ pub fn from_cli(cli_args: &Node) -> Result<Config, String> {
127128 . map_err ( |e| format ! ( "Failed to create {:?}: {:?}" , config. data_dir, e) ) ?;
128129 }
129130
130- if let Some ( beacon_nodes) = & cli_args. beacon_nodes {
131- config. beacon_nodes = beacon_nodes
132- . iter ( )
133- . map ( |s| SensitiveUrl :: parse ( s) )
134- . collect :: < Result < _ , _ > > ( )
135- . map_err ( |e| format ! ( "Unable to parse beacon node URL: {:?}" , e) ) ?;
131+ if let Some ( ref beacon_nodes) = cli_args. beacon_nodes {
132+ parse_urls ( & mut config. beacon_nodes , beacon_nodes, "beacon node" ) ?;
136133 }
137-
138- if let Some ( execution_nodes) = & cli_args. execution_nodes {
139- config. execution_nodes = execution_nodes
140- . iter ( )
141- . map ( |s| SensitiveUrl :: parse ( s) )
142- . collect :: < Result < _ , _ > > ( )
143- . map_err ( |e| format ! ( "Unable to parse execution node URL: {:?}" , e) ) ?;
134+ if let Some ( ref execution_rpc) = cli_args. execution_rpc {
135+ parse_urls ( & mut config. execution_nodes , execution_rpc, "execution RPC" ) ?;
136+ }
137+ if let Some ( ref execution_ws) = cli_args. execution_ws {
138+ parse_urls (
139+ & mut config. execution_nodes_websocket ,
140+ execution_ws,
141+ "execution WebSocket" ,
142+ ) ?;
144143 }
145144
146145 // Password to decrypt rsa key file
@@ -236,6 +235,16 @@ pub fn from_cli(cli_args: &Node) -> Result<Config, String> {
236235 Ok ( config)
237236}
238237
238+ /// Read SensitiveUrls from given CLI Strings
239+ fn parse_urls ( dest : & mut Vec < SensitiveUrl > , src : & [ String ] , kind : & str ) -> Result < ( ) , String > {
240+ * dest = src
241+ . iter ( )
242+ . map ( |s| SensitiveUrl :: parse ( s) )
243+ . collect :: < Result < _ , _ > > ( )
244+ . map_err ( |e| format ! ( "Unable to parse {kind} URL: {:?}" , e) ) ?;
245+ Ok ( ( ) )
246+ }
247+
239248/// Gets the listening_addresses for lighthouse based on the cli options.
240249pub fn parse_listening_addresses ( cli_args : & Node ) -> Result < ListenAddress , String > {
241250 // parse the possible ips
0 commit comments