Skip to content

Commit

Permalink
fix: update peer filter jsdoc comments (#2543)
Browse files Browse the repository at this point in the history
Adds more explanation about peer filter params.
  • Loading branch information
achingbrain authored May 14, 2024
1 parent 43046b9 commit 9d4b059
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions packages/peer-collections/src/filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import type { PeerId } from '@libp2p/interface'
import type { Filter } from '@libp2p/utils/filters'

/**
* Uses a Bloom filter to implement a mechansim for deduplicating PeerIds in a
* way that uses a fixed amount of memory.
* Uses a Cuckoo filter to implement a mechanism for deduplicating PeerIds in a
* way that uses a smaller amount of memory than a PeerSet.
*/
export class PeerFilter {
private readonly filter: Filter
Expand All @@ -26,6 +26,12 @@ export class PeerFilter {
}
}

export function peerFilter (size: number): PeerFilter {
return new PeerFilter(size)
/**
* Create and return a PeerFilter
*
* @param size - The maximum number of peers expected to be added to the filter
* @param errorRate - The acceptable error rate
*/
export function peerFilter (size: number, errorRate: number = 0.001): PeerFilter {
return new PeerFilter(size, errorRate)
}

0 comments on commit 9d4b059

Please sign in to comment.