Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(kad): remove default constructor for ProtocolConfig #5774

Merged
merged 4 commits into from
Jan 3, 2025
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
23 changes: 0 additions & 23 deletions protocols/kad/src/behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,29 +238,6 @@ impl Config {
}
}

/// Returns the default configuration.
#[deprecated(note = "Use `Config::new` instead")]
#[allow(clippy::should_implement_trait)]
pub fn default() -> Self {
Default::default()
}

/// Sets custom protocol names.
///
/// Kademlia nodes only communicate with other nodes using the same protocol
/// name. Using custom name(s) therefore allows to segregate the DHT from
/// others, if that is desired.
///
/// More than one protocol name can be supplied. In this case the node will
/// be able to talk to other nodes supporting any of the provided names.
/// Multiple names must be used with caution to avoid network partitioning.
#[deprecated(note = "Use `Config::new` instead")]
#[allow(deprecated)]
pub fn set_protocol_names(&mut self, names: Vec<StreamProtocol>) -> &mut Self {
self.protocol_config.set_protocol_names(names);
self
}

/// Sets the timeout for a single query.
///
/// > **Note**: A single query usually comprises at least as many requests
Expand Down
28 changes: 1 addition & 27 deletions protocols/kad/src/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
//! to poll the underlying transport for incoming messages, and the `Sink` component
//! is used to send messages to remote peers.

use std::{io, iter, marker::PhantomData, time::Duration};
use std::{io, marker::PhantomData, time::Duration};

use asynchronous_codec::{Decoder, Encoder, Framed};
use bytes::BytesMut;
Expand Down Expand Up @@ -156,43 +156,17 @@ impl ProtocolConfig {
}
}

/// Returns the default configuration.
#[deprecated(note = "Use `ProtocolConfig::new` instead")]
#[allow(clippy::should_implement_trait)]
pub fn default() -> Self {
Default::default()
}

/// Returns the configured protocol name.
pub fn protocol_names(&self) -> &[StreamProtocol] {
&self.protocol_names
}

/// Modifies the protocol names used on the wire. Can be used to create incompatibilities
/// between networks on purpose.
#[deprecated(note = "Use `ProtocolConfig::new` instead")]
pub fn set_protocol_names(&mut self, names: Vec<StreamProtocol>) {
self.protocol_names = names;
}

/// Modifies the maximum allowed size of a single Kademlia packet.
pub fn set_max_packet_size(&mut self, size: usize) {
self.max_packet_size = size;
}
}

impl Default for ProtocolConfig {
/// Returns the default configuration.
///
/// Deprecated: use `ProtocolConfig::new` instead.
fn default() -> Self {
ProtocolConfig {
protocol_names: iter::once(DEFAULT_PROTO_NAME).collect(),
max_packet_size: DEFAULT_MAX_PACKET_SIZE,
}
}
}

impl UpgradeInfo for ProtocolConfig {
type Info = StreamProtocol;
type InfoIter = std::vec::IntoIter<Self::Info>;
Expand Down
Loading