-
Notifications
You must be signed in to change notification settings - Fork 8
Open
Description
Unsolicited feedback. Feel free to ignore.
Given that you are supporting a single authentication protocol only, you might want to consider using Version::V1Lazy instead of V1, potentially saving you one round trip. See V1Lazy docs for details.
rendezvous-server/src/transport.rs
Lines 11 to 39 in b87efa3
| /// "Completes" a transport by applying the authentication and multiplexing | |
| /// upgrades. | |
| /// | |
| /// Even though the actual transport technology in use might be different, for | |
| /// two libp2p applications to be compatible, the authentication and | |
| /// multiplexing upgrades need to be compatible. | |
| pub fn authenticate_and_multiplex<T>( | |
| transport: Boxed<T>, | |
| identity: &identity::Keypair, | |
| ) -> Result<Boxed<(PeerId, StreamMuxerBox)>> | |
| where | |
| T: AsyncRead + AsyncWrite + Unpin + Send + 'static, | |
| { | |
| let auth_upgrade = { | |
| let noise_identity = noise::Keypair::<X25519Spec>::new().into_authentic(identity)?; | |
| NoiseConfig::xx(noise_identity).into_authenticated() | |
| }; | |
| let multiplex_upgrade = SelectUpgrade::new(yamux::YamuxConfig::default(), MplexConfig::new()); | |
| let transport = transport | |
| .upgrade(Version::V1) | |
| .authenticate(auth_upgrade) | |
| .multiplex(multiplex_upgrade) | |
| .timeout(Duration::from_secs(20)) | |
| .map(|(peer, muxer), _| (peer, StreamMuxerBox::new(muxer))) | |
| .boxed(); | |
| Ok(transport) | |
| } |
rishflab
Metadata
Metadata
Assignees
Labels
No labels