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 457c063
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
16 changes: 5 additions & 11 deletions protocols/identify/src/behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,17 +199,11 @@ 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| {
self.cache_config
.unwrap_or_default()
.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 457c063

Please sign in to comment.