Skip to content

Commit f4e5a8d

Browse files
authored
chore(kad): rename substreams_timeout
#6015 made the timeout for outbound substreams in kademlia configurable by introducing a `outbound_substreams_timeout` config option. There is currently an open PR #6009 that plans to also apply that timeout to inbound substream, in which case we probably want toe rename the config option to `substreams_timeout` (without the prefix). Because we plan to release soon and might not get #6009 in in-time, I propose that we already do the renaming now, to avoid breaking the API again with the next release. Pull-Request: #6076.
1 parent d996465 commit f4e5a8d

File tree

4 files changed

+16
-16
lines changed

4 files changed

+16
-16
lines changed

protocols/kad/CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
- Configurable outbound_substreams_timeout.
44
See [PR 6015](https://github.com/libp2p/rust-libp2p/pull/6015).
5-
5+
- Rename `outbound_substreams_timeout` to `substreams_timeout` for future-proofness.
6+
See [PR 6076](https://github.com/libp2p/rust-libp2p/pull/6076).
67
## 0.47.0
78

89
- Expose a kad query facility allowing specify num_results dynamically.

protocols/kad/src/behaviour.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -382,13 +382,12 @@ impl Config {
382382
self
383383
}
384384

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

protocols/kad/src/handler.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ impl Handler {
453453
}
454454
}
455455

456-
let outbound_substreams_timeout = protocol_config.outbound_substreams_timeout_s();
456+
let substreams_timeout = protocol_config.substreams_timeout_s();
457457

458458
Handler {
459459
protocol_config,
@@ -463,7 +463,7 @@ impl Handler {
463463
next_connec_unique_id: UniqueConnecId(0),
464464
inbound_substreams: Default::default(),
465465
outbound_substreams: futures_bounded::FuturesTupleSet::new(
466-
outbound_substreams_timeout,
466+
substreams_timeout,
467467
MAX_NUM_STREAMS,
468468
),
469469
pending_streams: Default::default(),

protocols/kad/src/protocol.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ pub(crate) const DEFAULT_PROTO_NAME: StreamProtocol = StreamProtocol::new("/ipfs
5050
/// The default maximum size for a varint length-delimited packet.
5151
pub(crate) const DEFAULT_MAX_PACKET_SIZE: usize = 16 * 1024;
5252
/// The default timeout of outbound_substreams to be 10 (seconds).
53-
const DEFAULT_OUTBOUND_SUBSTREAMS_TIMEOUT_S: Duration = Duration::from_secs(10);
53+
const DEFAULT_SUBSTREAMS_TIMEOUT_S: Duration = Duration::from_secs(10);
5454
/// Status of our connection to a node reported by the Kademlia protocol.
5555
#[derive(Copy, Clone, PartialEq, Eq, Debug, Hash)]
5656
pub enum ConnectionType {
@@ -148,7 +148,7 @@ pub struct ProtocolConfig {
148148
/// Maximum allowed size of a packet.
149149
max_packet_size: usize,
150150
/// Specifies the outbound_substreams timeout in seconds
151-
outbound_substreams_timeout_s: Duration,
151+
substreams_timeout_s: Duration,
152152
}
153153

154154
impl ProtocolConfig {
@@ -157,7 +157,7 @@ impl ProtocolConfig {
157157
ProtocolConfig {
158158
protocol_names: vec![protocol_name],
159159
max_packet_size: DEFAULT_MAX_PACKET_SIZE,
160-
outbound_substreams_timeout_s: DEFAULT_OUTBOUND_SUBSTREAMS_TIMEOUT_S,
160+
substreams_timeout_s: DEFAULT_SUBSTREAMS_TIMEOUT_S,
161161
}
162162
}
163163

@@ -171,14 +171,14 @@ impl ProtocolConfig {
171171
self.max_packet_size = size;
172172
}
173173

174-
/// Modifies outbount_substreams timeout.
175-
pub fn set_outbound_substreams_timeout(&mut self, timeout: Duration) {
176-
self.outbound_substreams_timeout_s = timeout;
174+
/// Modifies the outbound substreams timeout.
175+
pub fn set_substreams_timeout(&mut self, timeout: Duration) {
176+
self.substreams_timeout_s = timeout;
177177
}
178178

179-
/// Getter of outbount_substreams_timeout_s.
180-
pub fn outbound_substreams_timeout_s(&self) -> Duration {
181-
self.outbound_substreams_timeout_s
179+
/// Getter of substreams_timeout_s.
180+
pub fn substreams_timeout_s(&self) -> Duration {
181+
self.substreams_timeout_s
182182
}
183183
}
184184

0 commit comments

Comments
 (0)