mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-07-02 19:21:37 +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:
@ -55,7 +55,7 @@ impl MplexConfig {
|
||||
/// accumulates too quickly (judged by internal bounds), the
|
||||
/// connection is closed with an error due to the misbehaved
|
||||
/// remote.
|
||||
pub fn max_substreams(&mut self, max: usize) -> &mut Self {
|
||||
pub fn set_max_num_streams(&mut self, max: usize) -> &mut Self {
|
||||
self.max_substreams = max;
|
||||
self
|
||||
}
|
||||
@ -63,7 +63,7 @@ impl MplexConfig {
|
||||
/// Sets the maximum number of frames buffered per substream.
|
||||
///
|
||||
/// A limit is necessary in order to avoid DoS attacks.
|
||||
pub fn max_buffer_len(&mut self, max: usize) -> &mut Self {
|
||||
pub fn set_max_buffer_size(&mut self, max: usize) -> &mut Self {
|
||||
self.max_buffer_len = max;
|
||||
self
|
||||
}
|
||||
@ -72,14 +72,14 @@ impl MplexConfig {
|
||||
/// for a substream.
|
||||
///
|
||||
/// See the documentation of [`MaxBufferBehaviour`].
|
||||
pub fn max_buffer_len_behaviour(&mut self, behaviour: MaxBufferBehaviour) -> &mut Self {
|
||||
pub fn set_max_buffer_behaviour(&mut self, behaviour: MaxBufferBehaviour) -> &mut Self {
|
||||
self.max_buffer_behaviour = behaviour;
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets the frame size used when sending data. Capped at 1Mbyte as per the
|
||||
/// Mplex spec.
|
||||
pub fn split_send_size(&mut self, size: usize) -> &mut Self {
|
||||
pub fn set_split_send_size(&mut self, size: usize) -> &mut Self {
|
||||
let size = cmp::min(size, MAX_FRAME_SIZE);
|
||||
self.split_send_size = size;
|
||||
self
|
||||
|
Reference in New Issue
Block a user