Skip to content
Closed
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: 0 additions & 2 deletions protocols/kad/src/behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1993,7 +1993,6 @@ where
Ok(KademliaHandler::new(
KademliaHandlerConfig {
protocol_config: self.protocol_config.clone(),
allow_listening: true,
idle_timeout: self.connection_idle_timeout,
},
ConnectedPoint::Listener {
Expand All @@ -2014,7 +2013,6 @@ where
Ok(KademliaHandler::new(
KademliaHandlerConfig {
protocol_config: self.protocol_config.clone(),
allow_listening: true,
idle_timeout: self.connection_idle_timeout,
},
ConnectedPoint::Dialer {
Expand Down
14 changes: 1 addition & 13 deletions protocols/kad/src/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,6 @@ pub struct KademliaHandlerConfig {
/// Configuration of the wire protocol.
pub protocol_config: KademliaProtocolConfig,

/// If false, we deny incoming requests.
pub allow_listening: bool,

/// Time after which we close an idle connection.
pub idle_timeout: Duration,
}
Expand Down Expand Up @@ -534,8 +531,6 @@ where
<Self as ConnectionHandler>::InboundOpenInfo,
>,
) {
// If `self.allow_listening` is false, then we produced a `DeniedUpgrade` and `protocol`
// is a `Void`.
let protocol = match protocol {
future::Either::Left(p) => p,
future::Either::Right(p) => void::unreachable(p),
Expand Down Expand Up @@ -572,7 +567,6 @@ where
}
}

debug_assert!(self.config.allow_listening);
let connec_unique_id = self.next_connec_unique_id;
self.next_connec_unique_id.0 += 1;
self.inbound_substreams
Expand Down Expand Up @@ -618,12 +612,7 @@ where
type InboundOpenInfo = ();

fn listen_protocol(&self) -> SubstreamProtocol<Self::InboundProtocol, Self::InboundOpenInfo> {
if self.config.allow_listening {
SubstreamProtocol::new(self.config.protocol_config.clone(), ())
.map_upgrade(Either::Left)
} else {
SubstreamProtocol::new(Either::Right(upgrade::DeniedUpgrade), ())
}
SubstreamProtocol::new(self.config.protocol_config.clone(), ()).map_upgrade(Either::Left)
}

fn on_behaviour_event(&mut self, message: KademliaHandlerIn<TUserData>) {
Expand Down Expand Up @@ -812,7 +801,6 @@ impl Default for KademliaHandlerConfig {
fn default() -> Self {
KademliaHandlerConfig {
protocol_config: Default::default(),
allow_listening: true,
idle_timeout: Duration::from_secs(10),
}
}
Expand Down