Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion protocols/kad/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## 0.47.1

- Configurable outbound_substreams_timeout.
- Configurable substreams_timeout.
See [PR 6015](https://github.com/libp2p/rust-libp2p/pull/6015).

## 0.47.0
Expand Down
7 changes: 3 additions & 4 deletions protocols/kad/src/behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -382,13 +382,12 @@ impl Config {
self
}

/// Modifies the timeout duration of outbount_substreams.
/// Modifies the timeout duration of outbound substreams.
///
/// * Default to `10` seconds.
/// * May need to increase this value when sending large records with poor connection.
pub fn set_outbound_substreams_timeout(&mut self, timeout: Duration) -> &mut Self {
self.protocol_config
.set_outbound_substreams_timeout(timeout);
pub fn set_substreams_timeout(&mut self, timeout: Duration) -> &mut Self {
self.protocol_config.set_substreams_timeout(timeout);
self
}

Expand Down
4 changes: 2 additions & 2 deletions protocols/kad/src/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ impl Handler {
}
}

let outbound_substreams_timeout = protocol_config.outbound_substreams_timeout_s();
let substreams_timeout = protocol_config.substreams_timeout_s();

Handler {
protocol_config,
Expand All @@ -463,7 +463,7 @@ impl Handler {
next_connec_unique_id: UniqueConnecId(0),
inbound_substreams: Default::default(),
outbound_substreams: futures_bounded::FuturesTupleSet::new(
outbound_substreams_timeout,
substreams_timeout,
MAX_NUM_STREAMS,
),
pending_streams: Default::default(),
Expand Down
18 changes: 9 additions & 9 deletions protocols/kad/src/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ pub(crate) const DEFAULT_PROTO_NAME: StreamProtocol = StreamProtocol::new("/ipfs
/// The default maximum size for a varint length-delimited packet.
pub(crate) const DEFAULT_MAX_PACKET_SIZE: usize = 16 * 1024;
/// The default timeout of outbound_substreams to be 10 (seconds).
const DEFAULT_OUTBOUND_SUBSTREAMS_TIMEOUT_S: Duration = Duration::from_secs(10);
const DEFAULT_SUBSTREAMS_TIMEOUT_S: Duration = Duration::from_secs(10);
/// Status of our connection to a node reported by the Kademlia protocol.
#[derive(Copy, Clone, PartialEq, Eq, Debug, Hash)]
pub enum ConnectionType {
Expand Down Expand Up @@ -148,7 +148,7 @@ pub struct ProtocolConfig {
/// Maximum allowed size of a packet.
max_packet_size: usize,
/// Specifies the outbound_substreams timeout in seconds
outbound_substreams_timeout_s: Duration,
substreams_timeout_s: Duration,
}

impl ProtocolConfig {
Expand All @@ -157,7 +157,7 @@ impl ProtocolConfig {
ProtocolConfig {
protocol_names: vec![protocol_name],
max_packet_size: DEFAULT_MAX_PACKET_SIZE,
outbound_substreams_timeout_s: DEFAULT_OUTBOUND_SUBSTREAMS_TIMEOUT_S,
substreams_timeout_s: DEFAULT_SUBSTREAMS_TIMEOUT_S,
}
}

Expand All @@ -171,14 +171,14 @@ impl ProtocolConfig {
self.max_packet_size = size;
}

/// Modifies outbount_substreams timeout.
pub fn set_outbound_substreams_timeout(&mut self, timeout: Duration) {
self.outbound_substreams_timeout_s = timeout;
/// Modifies the outbound substreams timeout.
pub fn set_substreams_timeout(&mut self, timeout: Duration) {
self.substreams_timeout_s = timeout;
}

/// Getter of outbount_substreams_timeout_s.
pub fn outbound_substreams_timeout_s(&self) -> Duration {
self.outbound_substreams_timeout_s
/// Getter of substreams_timeout_s.
pub fn substreams_timeout_s(&self) -> Duration {
self.substreams_timeout_s
}
}

Expand Down
Loading