diff --git a/protocols/kad/CHANGELOG.md b/protocols/kad/CHANGELOG.md index 5cb94686f39..b9ba8b31d19 100644 --- a/protocols/kad/CHANGELOG.md +++ b/protocols/kad/CHANGELOG.md @@ -2,7 +2,8 @@ - Configurable outbound_substreams_timeout. See [PR 6015](https://github.com/libp2p/rust-libp2p/pull/6015). - +- Rename `outbound_substreams_timeout` to `substreams_timeout` for future-proofness. + See [PR 6076](https://github.com/libp2p/rust-libp2p/pull/6076). ## 0.47.0 - Expose a kad query facility allowing specify num_results dynamically. diff --git a/protocols/kad/src/behaviour.rs b/protocols/kad/src/behaviour.rs index f1c970024ac..5a48d30bca9 100644 --- a/protocols/kad/src/behaviour.rs +++ b/protocols/kad/src/behaviour.rs @@ -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 } diff --git a/protocols/kad/src/handler.rs b/protocols/kad/src/handler.rs index 7e3a67098ce..2c7b6c52257 100644 --- a/protocols/kad/src/handler.rs +++ b/protocols/kad/src/handler.rs @@ -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, @@ -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(), diff --git a/protocols/kad/src/protocol.rs b/protocols/kad/src/protocol.rs index 4be53dcd0e4..df181af1a86 100644 --- a/protocols/kad/src/protocol.rs +++ b/protocols/kad/src/protocol.rs @@ -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 { @@ -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 { @@ -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, } } @@ -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 } }