Skip to content

Commit

Permalink
don't make PeerAddressesConfig attributes public
Browse files Browse the repository at this point in the history
  • Loading branch information
stormshield-frb committed Sep 6, 2024
1 parent 4d17c21 commit 1b14122
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
15 changes: 4 additions & 11 deletions protocols/identify/src/behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,17 +199,10 @@ impl Config {
/// Configures the size of the LRU cache, caching addresses of discovered peers.
#[deprecated(since = "0.45.1", note = "Use `Config::with_cache_config` instead.")]
pub fn with_cache_size(mut self, cache_size: usize) -> Self {
match NonZeroUsize::new(cache_size) {
Some(cache_size) => {
if let Some(cache_config) = &mut self.cache_config {
cache_config.number_of_peers = cache_size;
} else {
self.cache_config =
Some(PeerAddressesConfig::default().with_number_of_peers(cache_size))
}
}
None => self.cache_config = None,
}
self.cache_config = NonZeroUsize::new(cache_size).map(|cache_size| {
let cache_config = self.cache_config.unwrap_or_default();
cache_config.with_number_of_peers(cache_size)
});
self
}

Expand Down
4 changes: 2 additions & 2 deletions swarm/src/behaviour/peer_addresses.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ use std::num::NonZeroUsize;
/// Configuration of a [`PeerAddresses`] instance.
pub struct PeerAddressesConfig {
/// Capacity of the [`PeerAddresses`] cache.
pub number_of_peers: NonZeroUsize,
number_of_peers: NonZeroUsize,

/// Maximum number of cached addresses per peer.
pub number_of_addresses_per_peer: NonZeroUsize,
number_of_addresses_per_peer: NonZeroUsize,
}

impl PeerAddressesConfig {
Expand Down

0 comments on commit 1b14122

Please sign in to comment.