@@ -23,6 +23,7 @@ use nym_topology::{EpochRewardedSet, NymTopology, RoutingNode};
2323use nym_validator_client:: client:: IdentityKey ;
2424use nym_validator_client:: { nym_api:: NymApiClientExt , UserAgent } ;
2525use rand:: thread_rng;
26+ use std:: time:: Duration ;
2627use url:: Url ;
2728use wasm_bindgen:: prelude:: wasm_bindgen;
2829use wasm_bindgen_futures:: future_to_promise;
@@ -127,6 +128,7 @@ pub async fn setup_gateway_wasm(
127128 force_tls : bool ,
128129 chosen_gateway : Option < IdentityKey > ,
129130 gateways : Vec < RoutingNode > ,
131+ connect_timeout : Option < Duration > ,
130132) -> Result < InitialisationResult , WasmCoreError > {
131133 // TODO: so much optimization and extra features could be added here, but that's for the future
132134
@@ -144,6 +146,7 @@ pub async fn setup_gateway_wasm(
144146 GatewaySetup :: New {
145147 specification : selection_spec,
146148 available_gateways : gateways,
149+ connect_timeout,
147150 }
148151 } ;
149152
@@ -159,6 +162,7 @@ pub async fn setup_gateway_from_api(
159162 nym_apis : & [ Url ] ,
160163 minimum_performance : u8 ,
161164 ignore_epoch_roles : bool ,
165+ connect_timeout : Option < Duration > ,
162166) -> Result < InitialisationResult , WasmCoreError > {
163167 let gateways = gateways_for_init (
164168 nym_apis,
@@ -168,7 +172,14 @@ pub async fn setup_gateway_from_api(
168172 None ,
169173 )
170174 . await ?;
171- setup_gateway_wasm ( client_store, force_tls, chosen_gateway, gateways) . await
175+ setup_gateway_wasm (
176+ client_store,
177+ force_tls,
178+ chosen_gateway,
179+ gateways,
180+ connect_timeout,
181+ )
182+ . await
172183}
173184
174185pub async fn current_gateways_wasm (
@@ -192,9 +203,17 @@ pub async fn setup_from_topology(
192203 force_tls : bool ,
193204 topology : & NymTopology ,
194205 client_store : & ClientStorage ,
206+ connect_timeout : Option < Duration > ,
195207) -> Result < InitialisationResult , WasmCoreError > {
196208 let gateways = topology. entry_capable_nodes ( ) . cloned ( ) . collect :: < Vec < _ > > ( ) ;
197- setup_gateway_wasm ( client_store, force_tls, explicit_gateway, gateways) . await
209+ setup_gateway_wasm (
210+ client_store,
211+ force_tls,
212+ explicit_gateway,
213+ gateways,
214+ connect_timeout,
215+ )
216+ . await
198217}
199218
200219pub async fn generate_new_client_keys ( store : & ClientStorage ) -> Result < ( ) , WasmCoreError > {
@@ -213,6 +232,7 @@ pub async fn add_gateway(
213232 min_performance : u8 ,
214233 ignore_epoch_roles : bool ,
215234 storage : & ClientStorage ,
235+ connect_timeout : Option < Duration > ,
216236) -> Result < ( ) , WasmCoreError > {
217237 let selection_spec = GatewaySelectionSpecification :: new (
218238 preferred_gateway. clone ( ) ,
@@ -267,6 +287,7 @@ pub async fn add_gateway(
267287 let gateway_setup = GatewaySetup :: New {
268288 specification : selection_spec,
269289 available_gateways,
290+ connect_timeout,
270291 } ;
271292
272293 let init_details = setup_gateway ( gateway_setup, storage, storage) . await ?;
0 commit comments