mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-06-13 01:51:23 +00:00
[mplex, yamux] Streamline configuration API. (#1822)
* Streamline mplex and yamux configurations. * For all configuration options that exist for both multiplexers and have the same semantics, use the same names for the configuration. * Rename `Config` to `YamuxConfig` for consistentcy with the majority of other protocols, e.g. `MplexConfig`, `PingConfig`, `KademliaConfig`, etc. * Completely hide `yamux` APIs within `libp2p-yamux`. This allows to fully control the libp2p API and streamline it with other muxer APIs, consciously choosing e.g. which configuration options to make configurable in libp2p and which to fix to certain values. It does also not necessarily prescribe new incompatible version bumps of yamux for `libp2p-yamux`, as no `yamux` types are exposed. The cost is some more duplication of configuration options in the API, as well as the need to update `libp2p-yamux` if `yamux` introduces new configuration options that `libp2p-yamux` wants to expose as well. * Update CHANGELOGs.
This commit is contained in:
@ -91,7 +91,7 @@
|
||||
//! let id_keys = Keypair::generate_ed25519();
|
||||
//! let noise_keys = noise::Keypair::<noise::X25519Spec>::new().into_authentic(&id_keys).unwrap();
|
||||
//! let noise = noise::NoiseConfig::xx(noise_keys).into_authenticated();
|
||||
//! let yamux = yamux::Config::default();
|
||||
//! let yamux = yamux::YamuxConfig::default();
|
||||
//! let transport = tcp.upgrade(upgrade::Version::V1).authenticate(noise).multiplex(yamux);
|
||||
//! # }
|
||||
//! ```
|
||||
@ -302,7 +302,7 @@ pub fn build_tcp_ws_noise_mplex_yamux(keypair: identity::Keypair)
|
||||
Ok(transport
|
||||
.upgrade(core::upgrade::Version::V1)
|
||||
.authenticate(noise::NoiseConfig::xx(noise_keys).into_authenticated())
|
||||
.multiplex(core::upgrade::SelectUpgrade::new(yamux::Config::default(), mplex::MplexConfig::new()))
|
||||
.multiplex(core::upgrade::SelectUpgrade::new(yamux::YamuxConfig::default(), mplex::MplexConfig::default()))
|
||||
.timeout(std::time::Duration::from_secs(20))
|
||||
.boxed())
|
||||
}
|
||||
@ -334,7 +334,7 @@ pub fn build_tcp_ws_pnet_noise_mplex_yamux(keypair: identity::Keypair, psk: PreS
|
||||
.and_then(move |socket, _| PnetConfig::new(psk).handshake(socket))
|
||||
.upgrade(core::upgrade::Version::V1)
|
||||
.authenticate(noise::NoiseConfig::xx(noise_keys).into_authenticated())
|
||||
.multiplex(core::upgrade::SelectUpgrade::new(yamux::Config::default(), mplex::MplexConfig::new()))
|
||||
.multiplex(core::upgrade::SelectUpgrade::new(yamux::YamuxConfig::default(), mplex::MplexConfig::default()))
|
||||
.timeout(std::time::Duration::from_secs(20))
|
||||
.boxed())
|
||||
}
|
||||
|
Reference in New Issue
Block a user