Skip to content

Commit

Permalink
chore(kad): remove default constructor for ProtocolConfig
Browse files Browse the repository at this point in the history
Remove items that were deprecated in #5122.

Pull-Request: #5774.
  • Loading branch information
drHuangMHT authored Jan 3, 2025
1 parent 02040ff commit 40550dc
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 50 deletions.
2 changes: 2 additions & 0 deletions protocols/kad/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
See [PR 5705](https://github.com/libp2p/rust-libp2p/pull/5705).
- Fix systematic memory allocation when iterating over `KBuckets`.
See [PR 5715](https://github.com/libp2p/rust-libp2p/pull/5715).
- Remove deprecated default constructor for `ProtocolConfig`.
See [PR 5774](https://github.com/libp2p/rust-libp2p/pull/5774).

## 0.46.2

Expand Down
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

0 comments on commit 40550dc

Please sign in to comment.