-
Notifications
You must be signed in to change notification settings - Fork 18
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
Networking & Other Refactoring #115
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a lot nicer! Only two of my comments are actual change requests. Feel free to resolve the others.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
core/network/src/peer/outbound.rs
Outdated
let peer_node_id = node::Id::from_cert_der_bytes(&peer_certificate.0)?; | ||
info!( | ||
"successfully connected to {} (total {} certificates, first cert {}-byte)", | ||
peer_node_id, | ||
peer_certs.len(), | ||
other_certificates.len() + 1, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't use other_certificates
. It would probably be better to do the following:
let (peer_certificate, total_certificates) = conn
.peer_certificates()
.and_then(|certs| {
let total_certs = certs.len();
certs.split_first().map(|(first, _)| (first, total_certs))
})
.ok_or(Error::new(
ErrorKind::NotConnected,
"no peer certificate found",
))?;
let peer_node_id = node::Id::from_cert_der_bytes(&peer_certificate.0)?;
info!(
"successfully connected to {} (total {} certificates, first cert {}-byte)",
peer_node_id,
total_certificates,
peer_certificate.0.len(),
);
@@ -153,7 +138,7 @@ fn test_connector() { | |||
/// Represents a connection to a peer. | |||
/// ref. <https://github.com/rustls/rustls/commit/b8024301747fb0328c9493d7cf7268e0de17ffb3> | |||
pub struct Stream { | |||
pub addr: String, | |||
pub addr: SocketAddr, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
.iter() | ||
.map(|id| id.to_vec()) | ||
.map(prost::bytes::Bytes::from) | ||
.collect(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Much nicer, 🥇
@dimitrovmaksim, @Angel-Petrov has an unsigned commit on this branch. If one of you can sign that commit, we can merge. |
Signed-off-by: Maksim Dimitrov <dimitrov.maksim@gmail.com>
Signed-off-by: Maksim Dimitrov <dimitrov.maksim@gmail.com>
a878b7a
to
4891b06
Compare
I signed it, hopefully I did not break something else 😅 |
What this PR does:
array::from_fn
to avoid duplication when generating random IDsip: IpAddr, port: u16
instead haveSocketAddr
Message::tracked_subnets
accept any slice instead of just Vecs (overly strict type for what is needed)io::error::ErrorKind::Other