Skip to content

Commit 5184663

Browse files
dknopikelenaf9
andcommitted
Clean up doc comments.
Co-authored-by: Elena Frank <[email protected]>
1 parent b374492 commit 5184663

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

misc/peer-store/src/memory_store.rs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ pub enum Event {
2929

3030
/// A in-memory store that uses LRU cache for bounded storage of addresses
3131
/// and a frequency-based ordering of addresses.
32-
///
33-
///
3432
#[derive(Default)]
3533
pub struct MemoryStore<T = ()> {
3634
/// The internal store.
@@ -67,7 +65,8 @@ impl<T> MemoryStore<T> {
6765
is_updated
6866
}
6967

70-
/// Update an address record without notifying swarm.
68+
/// Update an address record without notifying swarm.
69+
///
7170
/// Returns `true` when the address is new.
7271
fn update_address_silent(
7372
&mut self,
@@ -86,7 +85,7 @@ impl<T> MemoryStore<T> {
8685

8786
/// Remove an address record.
8887
///
89-
/// Returns `true` when the address is removed.
88+
/// Returns `true` when the address existed.
9089
pub fn remove_address(&mut self, peer: &PeerId, address: &Multiaddr) -> bool {
9190
let is_updated = self.remove_address_silent(peer, address, true);
9291
if is_updated {
@@ -96,7 +95,9 @@ impl<T> MemoryStore<T> {
9695
}
9796

9897
/// Remove an address record without notifying swarm.
99-
/// Returns `true` when the address is removed.
98+
///
99+
/// Returns `true` when the address is removed, `false` if the address didn't exist
100+
/// or the address is permanent and `force` false.
100101
fn remove_address_silent(&mut self, peer: &PeerId, address: &Multiaddr, force: bool) -> bool {
101102
if let Some(record) = self.records.get_mut(peer) {
102103
if record.remove_address(address, force) {
@@ -293,7 +294,7 @@ impl Config {
293294
pub struct PeerRecord<T> {
294295
/// A LRU(Least Recently Used) cache for addresses.
295296
/// Will delete the least-recently-used record when full.
296-
/// If the associated `bool` is true, the address can only be force-removed
297+
/// If the associated `bool` is true, the address can only be force-removed.
297298
addresses: LruCache<Multiaddr, bool>,
298299
/// Custom data attached to the peer.
299300
custom_data: Option<T>,
@@ -314,6 +315,7 @@ impl<T> PeerRecord<T> {
314315

315316
/// Update the address in the LRU cache, promote it to the front if it exists,
316317
/// insert it to the front if not.
318+
///
317319
/// Returns true when the address is new.
318320
pub fn update_address(&mut self, address: &Multiaddr, permanent: bool) -> bool {
319321
if let Some(was_permanent) = self.addresses.get(address) {
@@ -327,7 +329,9 @@ impl<T> PeerRecord<T> {
327329
}
328330

329331
/// Remove the address in the LRU cache regardless of its position.
330-
/// Returns true when the address is removed, false when not exist.
332+
///
333+
/// Returns true when the address is removed, false when it didn't exist
334+
/// or it is permanent and `force` is false.
331335
pub fn remove_address(&mut self, address: &Multiaddr, force: bool) -> bool {
332336
if !force && self.addresses.peek(address) == Some(&true) {
333337
return false;

0 commit comments

Comments
 (0)