mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-04-25 03:02:12 +00:00
Allow OneShotHandler's max_dial_negotiate
limit to be configurable. (#1936)
* Allow OneShotHandler's `max_dial_negotiate` limit to be configurable. * Update version and CHANGELOG., Co-authored-by: Roman S. Borschel <roman@parity.io> Co-authored-by: Roman Borschel <romanb@users.noreply.github.com>
This commit is contained in:
parent
ac9798297b
commit
8aeb7b3db0
@ -1,3 +1,8 @@
|
|||||||
|
# 0.27.1 [unreleased]
|
||||||
|
|
||||||
|
- Make `OneShotHandler`s `max_dial_negotiate` limit configurable.
|
||||||
|
[PR 1936](https://github.com/libp2p/rust-libp2p/pull/1936).
|
||||||
|
|
||||||
# 0.27.0 [2021-01-12]
|
# 0.27.0 [2021-01-12]
|
||||||
|
|
||||||
- Update dependencies.
|
- Update dependencies.
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
name = "libp2p-swarm"
|
name = "libp2p-swarm"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
description = "The libp2p swarm"
|
description = "The libp2p swarm"
|
||||||
version = "0.27.0"
|
version = "0.27.1"
|
||||||
authors = ["Parity Technologies <admin@parity.io>"]
|
authors = ["Parity Technologies <admin@parity.io>"]
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
repository = "https://github.com/libp2p/rust-libp2p"
|
repository = "https://github.com/libp2p/rust-libp2p"
|
||||||
|
@ -47,8 +47,6 @@ where
|
|||||||
dial_queue: SmallVec<[TOutbound; 4]>,
|
dial_queue: SmallVec<[TOutbound; 4]>,
|
||||||
/// Current number of concurrent outbound substreams being opened.
|
/// Current number of concurrent outbound substreams being opened.
|
||||||
dial_negotiated: u32,
|
dial_negotiated: u32,
|
||||||
/// Maximum number of concurrent outbound substreams being opened. Value is never modified.
|
|
||||||
max_dial_negotiated: u32,
|
|
||||||
/// Value to return from `connection_keep_alive`.
|
/// Value to return from `connection_keep_alive`.
|
||||||
keep_alive: KeepAlive,
|
keep_alive: KeepAlive,
|
||||||
/// The configuration container for the handler
|
/// The configuration container for the handler
|
||||||
@ -71,7 +69,6 @@ where
|
|||||||
events_out: SmallVec::new(),
|
events_out: SmallVec::new(),
|
||||||
dial_queue: SmallVec::new(),
|
dial_queue: SmallVec::new(),
|
||||||
dial_negotiated: 0,
|
dial_negotiated: 0,
|
||||||
max_dial_negotiated: 8,
|
|
||||||
keep_alive: KeepAlive::Yes,
|
keep_alive: KeepAlive::Yes,
|
||||||
config,
|
config,
|
||||||
}
|
}
|
||||||
@ -204,7 +201,7 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !self.dial_queue.is_empty() {
|
if !self.dial_queue.is_empty() {
|
||||||
if self.dial_negotiated < self.max_dial_negotiated {
|
if self.dial_negotiated < self.config.max_dial_negotiated {
|
||||||
self.dial_negotiated += 1;
|
self.dial_negotiated += 1;
|
||||||
let upgrade = self.dial_queue.remove(0);
|
let upgrade = self.dial_queue.remove(0);
|
||||||
return Poll::Ready(
|
return Poll::Ready(
|
||||||
@ -233,6 +230,8 @@ pub struct OneShotHandlerConfig {
|
|||||||
pub keep_alive_timeout: Duration,
|
pub keep_alive_timeout: Duration,
|
||||||
/// Timeout for outbound substream upgrades.
|
/// Timeout for outbound substream upgrades.
|
||||||
pub outbound_substream_timeout: Duration,
|
pub outbound_substream_timeout: Duration,
|
||||||
|
/// Maximum number of concurrent outbound substreams being opened.
|
||||||
|
pub max_dial_negotiated: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for OneShotHandlerConfig {
|
impl Default for OneShotHandlerConfig {
|
||||||
@ -240,6 +239,7 @@ impl Default for OneShotHandlerConfig {
|
|||||||
OneShotHandlerConfig {
|
OneShotHandlerConfig {
|
||||||
keep_alive_timeout: Duration::from_secs(10),
|
keep_alive_timeout: Duration::from_secs(10),
|
||||||
outbound_substream_timeout: Duration::from_secs(10),
|
outbound_substream_timeout: Duration::from_secs(10),
|
||||||
|
max_dial_negotiated: 8,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user