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

fix(core/choice): log on dial and fix listen log #4164

Merged
merged 2 commits into from
Jul 10, 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
36 changes: 30 additions & 6 deletions core/src/transport/choice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ where
addr: Multiaddr,
) -> Result<(), TransportError<Self::Error>> {
trace!(
"Attempting to dial {} using {}",
"Attempting to listen on {} using {}",
addr,
std::any::type_name::<A>()
);
let addr = match self.0.listen_on(id, addr) {
Err(TransportError::MultiaddrNotSupported(addr)) => {
debug!(
"Failed to dial {} using {}",
"Failed to listen on {} using {}",
addr,
std::any::type_name::<A>()
);
Expand All @@ -70,14 +70,14 @@ where
};

trace!(
"Attempting to dial {} using {}",
"Attempting to listen on {} using {}",
addr,
std::any::type_name::<B>()
);
let addr = match self.1.listen_on(id, addr) {
Err(TransportError::MultiaddrNotSupported(addr)) => {
debug!(
"Failed to dial {} using {}",
"Failed to listen on {} using {}",
addr,
std::any::type_name::<B>()
);
Expand All @@ -94,17 +94,41 @@ where
}

fn dial(&mut self, addr: Multiaddr) -> Result<Self::Dial, TransportError<Self::Error>> {
trace!(
"Attempting to dial {} using {}",
addr,
std::any::type_name::<A>()
);
let addr = match self.0.dial(addr) {
Ok(connec) => return Ok(EitherFuture::First(connec)),
Err(TransportError::MultiaddrNotSupported(addr)) => addr,
Err(TransportError::MultiaddrNotSupported(addr)) => {
debug!(
"Failed to dial {} using {}",
addr,
std::any::type_name::<A>()
);
addr
}
Err(TransportError::Other(err)) => {
return Err(TransportError::Other(Either::Left(err)))
}
};

trace!(
"Attempting to dial {} using {}",
addr,
std::any::type_name::<A>()
);
let addr = match self.1.dial(addr) {
Ok(connec) => return Ok(EitherFuture::Second(connec)),
Err(TransportError::MultiaddrNotSupported(addr)) => addr,
Err(TransportError::MultiaddrNotSupported(addr)) => {
debug!(
"Failed to dial {} using {}",
addr,
std::any::type_name::<A>()
);
addr
}
Err(TransportError::Other(err)) => {
return Err(TransportError::Other(Either::Right(err)))
}
Expand Down