Skip to content

Commit 7b42377

Browse files
committed
refactor: address review
1 parent 368f92d commit 7b42377

4 files changed

Lines changed: 13 additions & 12 deletions

File tree

msg-transport/Cargo.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ async-trait.workspace = true
1717
futures.workspace = true
1818
tokio.workspace = true
1919
tracing.workspace = true
20-
21-
thiserror = { workspace = true, optional = true }
20+
thiserror.workspace = true
2221

2322
# QUIC
2423
quinn = { workspace = true, optional = true }
@@ -29,4 +28,4 @@ tracing-subscriber = "0.3"
2928

3029
[features]
3130
default = []
32-
quic = ["dep:quinn", "dep:rcgen", "dep:thiserror"]
31+
quic = ["dep:quinn", "dep:rcgen"]

msg-transport/src/lib.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,17 @@ pub trait TransportExt<A: Address>: Transport<A> {
7878
}
7979
}
8080

81+
/// An `await`-friendly interface for accepting inbound connections.
82+
///
83+
/// This struct is used to accept inbound connections from a transport. It is
84+
/// created using the [`TransportExt::accept`] method.
8185
pub struct Acceptor<'a, T, A>
8286
where
8387
T: Transport<A>,
8488
A: Address,
8589
{
8690
inner: &'a mut T,
91+
/// The pending [`Transport::Accept`] future.
8792
pending: Option<T::Accept>,
8893
_marker: PhantomData<A>,
8994
}
@@ -109,6 +114,7 @@ where
109114
let this = self.get_mut();
110115

111116
loop {
117+
// If there's a pending accept future, poll it to completion
112118
if let Some(pending) = this.pending.as_mut() {
113119
match pending.poll_unpin(cx) {
114120
Poll::Ready(res) => {
@@ -119,6 +125,7 @@ where
119125
}
120126
}
121127

128+
// Otherwise, poll the transport for a new accept future
122129
match Pin::new(&mut *this.inner).poll_accept(cx) {
123130
Poll::Ready(accept) => {
124131
this.pending = Some(accept);

msg-transport/src/quic/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ mod tests {
254254
let (tx, rx) = oneshot::channel();
255255

256256
tokio::spawn(async move {
257-
// tokio::time::sleep(Duration::from_secs(1)).await;
257+
tokio::time::sleep(Duration::from_secs(1)).await;
258258

259259
let mut stream = server.accept().await.unwrap();
260260

msg-transport/src/quic/tls.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ impl ServerCertVerifier for SkipServerVerification {
3030
_ocsp_response: &[u8],
3131
_now: rustls::pki_types::UnixTime,
3232
) -> Result<rustls::client::danger::ServerCertVerified, rustls::Error> {
33-
tracing::debug!(target = "quic.tls", "Skipping server verification");
33+
tracing::debug!("skipping server verification");
3434
Ok(ServerCertVerified::assertion())
3535
}
3636

@@ -40,7 +40,7 @@ impl ServerCertVerifier for SkipServerVerification {
4040
cert: &rustls::pki_types::CertificateDer<'_>,
4141
dss: &rustls::DigitallySignedStruct,
4242
) -> Result<rustls::client::danger::HandshakeSignatureValid, rustls::Error> {
43-
tracing::debug!(target = "quic.tls", "Verifying TLS 1.2 signature");
43+
tracing::debug!("verifying TLS 1.2 signature");
4444
rustls::crypto::verify_tls12_signature(
4545
message,
4646
cert,
@@ -55,7 +55,7 @@ impl ServerCertVerifier for SkipServerVerification {
5555
cert: &rustls::pki_types::CertificateDer<'_>,
5656
dss: &rustls::DigitallySignedStruct,
5757
) -> Result<rustls::client::danger::HandshakeSignatureValid, rustls::Error> {
58-
tracing::debug!(target = "quic.tls", "Verifying TLS 1.3 signature");
58+
tracing::debug!("verifying TLS 1.3 signature");
5959
rustls::crypto::verify_tls13_signature(
6060
message,
6161
cert,
@@ -65,11 +65,6 @@ impl ServerCertVerifier for SkipServerVerification {
6565
}
6666

6767
fn supported_verify_schemes(&self) -> Vec<SignatureScheme> {
68-
tracing::debug!(
69-
target = "quic.tls",
70-
"Supported verify schemes: {:?}",
71-
self.0.signature_verification_algorithms.supported_schemes()
72-
);
7368
self.0.signature_verification_algorithms.supported_schemes()
7469
}
7570
}

0 commit comments

Comments
 (0)