Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(core): add logs for OrTransport when trying addresses #4133

Merged
merged 7 commits into from
Jul 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 27 additions & 2 deletions core/src/transport/choice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ use crate::either::EitherFuture;
use crate::transport::{ListenerId, Transport, TransportError, TransportEvent};
use either::Either;
use futures::future;
use log::{debug, trace};
use multiaddr::Multiaddr;
use std::{pin::Pin, task::Context, task::Poll};

Expand Down Expand Up @@ -51,13 +52,37 @@ where
id: ListenerId,
addr: Multiaddr,
) -> Result<(), TransportError<Self::Error>> {
trace!(
"Attempting to dial {} using {}",
addr,
std::any::type_name::<A>()
);
let addr = match self.0.listen_on(id, addr) {
Err(TransportError::MultiaddrNotSupported(addr)) => addr,
Err(TransportError::MultiaddrNotSupported(addr)) => {
debug!(
"Failed to dial {} using {}",
addr,
std::any::type_name::<A>()
);
addr
}
res => return res.map_err(|err| err.map(Either::Left)),
};

trace!(
"Attempting to dial {} using {}",
addr,
std::any::type_name::<B>()
);
let addr = match self.1.listen_on(id, addr) {
Err(TransportError::MultiaddrNotSupported(addr)) => addr,
Err(TransportError::MultiaddrNotSupported(addr)) => {
debug!(
"Failed to dial {} using {}",
addr,
std::any::type_name::<B>()
);
addr
}
res => return res.map_err(|err| err.map(Either::Right)),
};

Expand Down