@@ -295,7 +295,7 @@ where
295
295
} ) {
296
296
if dns_lookups == MAX_DNS_LOOKUPS {
297
297
tracing:: debug!( address=%addr, "Too many DNS lookups, dropping unresolved address" ) ;
298
- dial_errors. push ( Error :: TooManyLookups ) ; // this is imp
298
+ dial_errors. push ( Error :: TooManyLookups ) ;
299
299
// There may still be fully resolved addresses in `unresolved`,
300
300
// so keep going until `unresolved` is empty.
301
301
continue ;
@@ -366,38 +366,33 @@ where
366
366
Err ( err) => {
367
367
tracing:: debug!( "Dial error: {:?}." , err) ;
368
368
dial_errors. push ( err) ;
369
+
370
+ if unresolved. is_empty ( ) {
371
+ // If there are no further addresses to try—or we've hit the limit—
372
+ // break out of the loop.
373
+ break ;
374
+ }
375
+
369
376
if dial_attempts == MAX_DIAL_ATTEMPTS {
370
377
tracing:: debug!(
371
378
"Aborting dialing after {} attempts." ,
372
379
MAX_DIAL_ATTEMPTS
373
380
) ;
374
381
break ;
375
382
}
376
- if unresolved. is_empty ( ) {
377
- // If there are no further addresses to try—or we've hit the limit—
378
- // break out of the loop.
379
- break ;
380
- }
383
+
381
384
}
382
385
}
383
386
}
384
387
}
385
-
386
- // At this point, if there was at least one failed dialing
387
- // attempt, return that error. Otherwise there were no valid DNS records
388
- // for the given address to begin with (i.e. DNS lookups succeeded but
389
- // produced no records relevant for the given `addr`).
388
+ // If we have any dial errors, aggregate them. Otherwise, report that no valid
389
+ // DNS records were found for the address.
390
390
if !dial_errors. is_empty ( ) {
391
- if dial_errors. len ( ) ==1 {
392
- Err ( dial_errors. pop ( ) . unwrap ( ) )
393
- } else {
394
- Err ( Error :: DialErrors ( dial_errors) )
395
- }
391
+ Err ( Error :: Dial ( dial_errors) )
396
392
} else {
397
393
Err ( Error :: ResolveError ( ResolveErrorKind :: Message ( "No Matching Records Found" ) . into ( ) ) )
398
394
}
399
-
400
- }
395
+ }
401
396
. boxed ( )
402
397
. right_future ( )
403
398
}
@@ -422,7 +417,7 @@ pub enum Error<TErr> {
422
417
/// should be investigated.
423
418
TooManyLookups ,
424
419
/// Multiple dial errors were encountered.
425
- DialErrors ( Vec < Error < TErr > > ) ,
420
+ Dial ( Vec < Error < TErr > > ) ,
426
421
}
427
422
428
423
impl < TErr > fmt:: Display for Error < TErr >
@@ -435,7 +430,7 @@ where
435
430
Error :: ResolveError ( err) => write ! ( f, "{err}" ) ,
436
431
Error :: MultiaddrNotSupported ( a) => write ! ( f, "Unsupported resolved address: {a}" ) ,
437
432
Error :: TooManyLookups => write ! ( f, "Too many DNS lookups" ) ,
438
- Error :: DialErrors ( errs) => {
433
+ Error :: Dial ( errs) => {
439
434
write ! ( f, "Multiple dial errors occured:" ) ?;
440
435
for err in errs {
441
436
write ! ( f, "/n - {err}" ) ?;
@@ -456,7 +451,7 @@ where
456
451
Error :: ResolveError ( err) => Some ( err) ,
457
452
Error :: MultiaddrNotSupported ( _) => None ,
458
453
Error :: TooManyLookups => None ,
459
- Error :: DialErrors ( errs) => errs. first ( ) . and_then ( |e| e. source ( ) ) ,
454
+ Error :: Dial ( errs) => errs. first ( ) . and_then ( |e| e. source ( ) ) ,
460
455
}
461
456
}
462
457
}
@@ -819,7 +814,7 @@ mod tests {
819
814
fn listen_on (
820
815
& mut self ,
821
816
_id : ListenerId ,
822
- _addr : Multiaddr ,
817
+ addr : Multiaddr ,
823
818
) -> Result < ( ) , TransportError < Self :: Error > > {
824
819
unimplemented ! ( )
825
820
}
@@ -831,7 +826,7 @@ mod tests {
831
826
fn dial (
832
827
& mut self ,
833
828
_addr : Multiaddr ,
834
- _opts : DialOpts ,
829
+ _ : DialOpts ,
835
830
) -> Result < Self :: Dial , TransportError < Self :: Error > > {
836
831
// Every dial attempt fails with an error that includes the address.
837
832
Ok ( Box :: pin ( future:: ready ( Err ( io:: Error :: new (
@@ -867,7 +862,7 @@ mod tests {
867
862
let result = dial_future. await ;
868
863
869
864
match result {
870
- Err ( Error :: DialErrors ( errs) ) => {
865
+ Err ( Error :: Dial ( errs) ) => {
871
866
// We expect at least 2 errors, one per resolved IP.
872
867
assert ! (
873
868
errs. len( ) >= 2 ,
0 commit comments