@@ -19,6 +19,7 @@ use tokio_util::sync::CancellationToken;
1919use crate :: error:: RegistrationClientError ;
2020
2121const VPN_AVERAGE_PACKET_DELAY : Duration = Duration :: from_millis ( 15 ) ;
22+ const MIXNET_CLIENT_STARTUP_TIMEOUT : Duration = Duration :: from_secs ( 30 ) ;
2223
2324#[ derive( Clone ) ]
2425pub struct NymNodeWithKeys {
@@ -31,6 +32,7 @@ pub struct BuilderConfig {
3132 pub exit_node : NymNodeWithKeys ,
3233 pub data_path : Option < PathBuf > ,
3334 pub mixnet_client_config : MixnetClientConfig ,
35+ pub mixnet_client_startup_timeout : Duration ,
3436 pub two_hops : bool ,
3537 pub user_agent : UserAgent ,
3638 pub custom_topology_provider : Box < dyn TopologyProvider + Send + Sync > ,
@@ -56,37 +58,6 @@ pub struct MixnetClientConfig {
5658}
5759
5860impl BuilderConfig {
59- /// Creates a new BuilderConfig with all required parameters.
60- ///
61- /// However, consider using `BuilderConfig::builder()` instead.
62- #[ allow( clippy:: too_many_arguments) ]
63- pub fn new (
64- entry_node : NymNodeWithKeys ,
65- exit_node : NymNodeWithKeys ,
66- data_path : Option < PathBuf > ,
67- mixnet_client_config : MixnetClientConfig ,
68- two_hops : bool ,
69- user_agent : UserAgent ,
70- custom_topology_provider : Box < dyn TopologyProvider + Send + Sync > ,
71- network_env : NymNetworkDetails ,
72- cancel_token : CancellationToken ,
73- #[ cfg( unix) ] connection_fd_callback : Arc < dyn Fn ( RawFd ) + Send + Sync > ,
74- ) -> Self {
75- Self {
76- entry_node,
77- exit_node,
78- data_path,
79- mixnet_client_config,
80- two_hops,
81- user_agent,
82- custom_topology_provider,
83- network_env,
84- cancel_token,
85- #[ cfg( unix) ]
86- connection_fd_callback,
87- }
88- }
89-
9061 /// Creates a builder for BuilderConfig
9162 ///
9263 /// This is the preferred way to construct a BuilderConfig.
@@ -287,6 +258,7 @@ pub struct BuilderConfigBuilder {
287258 exit_node : Option < NymNodeWithKeys > ,
288259 data_path : Option < PathBuf > ,
289260 mixnet_client_config : Option < MixnetClientConfig > ,
261+ mixnet_client_startup_timeout : Duration ,
290262 two_hops : bool ,
291263 user_agent : Option < UserAgent > ,
292264 custom_topology_provider : Option < Box < dyn TopologyProvider + Send + Sync > > ,
@@ -298,39 +270,58 @@ pub struct BuilderConfigBuilder {
298270
299271impl BuilderConfigBuilder {
300272 pub fn new ( ) -> Self {
301- Self :: default ( )
273+ Self {
274+ mixnet_client_startup_timeout : MIXNET_CLIENT_STARTUP_TIMEOUT ,
275+ ..Default :: default ( )
276+ }
302277 }
303278
279+ #[ must_use]
304280 pub fn entry_node ( mut self , entry_node : NymNodeWithKeys ) -> Self {
305281 self . entry_node = Some ( entry_node) ;
306282 self
307283 }
308284
285+ #[ must_use]
309286 pub fn exit_node ( mut self , exit_node : NymNodeWithKeys ) -> Self {
310287 self . exit_node = Some ( exit_node) ;
311288 self
312289 }
313290
291+ #[ must_use]
314292 pub fn data_path ( mut self , data_path : Option < PathBuf > ) -> Self {
315293 self . data_path = data_path;
316294 self
317295 }
318296
297+ #[ must_use]
319298 pub fn mixnet_client_config ( mut self , mixnet_client_config : MixnetClientConfig ) -> Self {
320299 self . mixnet_client_config = Some ( mixnet_client_config) ;
321300 self
322301 }
323302
303+ #[ must_use]
304+ pub fn mixnet_client_startup_timeout (
305+ mut self ,
306+ mixnet_client_startup_timeout : Duration ,
307+ ) -> Self {
308+ self . mixnet_client_startup_timeout = mixnet_client_startup_timeout;
309+ self
310+ }
311+
312+ #[ must_use]
324313 pub fn two_hops ( mut self , two_hops : bool ) -> Self {
325314 self . two_hops = two_hops;
326315 self
327316 }
328317
318+ #[ must_use]
329319 pub fn user_agent ( mut self , user_agent : UserAgent ) -> Self {
330320 self . user_agent = Some ( user_agent) ;
331321 self
332322 }
333323
324+ #[ must_use]
334325 pub fn custom_topology_provider (
335326 mut self ,
336327 custom_topology_provider : Box < dyn TopologyProvider + Send + Sync > ,
@@ -339,11 +330,13 @@ impl BuilderConfigBuilder {
339330 self
340331 }
341332
333+ #[ must_use]
342334 pub fn network_env ( mut self , network_env : NymNetworkDetails ) -> Self {
343335 self . network_env = Some ( network_env) ;
344336 self
345337 }
346338
339+ #[ must_use]
347340 pub fn cancel_token ( mut self , cancel_token : CancellationToken ) -> Self {
348341 self . cancel_token = Some ( cancel_token) ;
349342 self
@@ -371,6 +364,7 @@ impl BuilderConfigBuilder {
371364 mixnet_client_config : self
372365 . mixnet_client_config
373366 . ok_or ( BuilderConfigError :: MissingMixnetClientConfig ) ?,
367+ mixnet_client_startup_timeout : self . mixnet_client_startup_timeout ,
374368 two_hops : self . two_hops ,
375369 user_agent : self
376370 . user_agent
0 commit comments