@libp2p/peer-collections 6.0.27 → 6.0.28-aa25d38ab

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -11,7 +11,24 @@ export declare class PeerFilter {
11
11
  remove(peerId: PeerId): void;
12
12
  }
13
13
  /**
14
- * Create and return a PeerFilter
14
+ * Create and return a PeerFilter. This can be used by topologies to prevent
15
+ * them receiving duplicate notifications for a peer that connects repeatedly.
16
+ *
17
+ * @example
18
+ *
19
+ * ```TypeScript
20
+ * import { peerFilter } from '@libp2p/peer-collections'
21
+ * import type { Registrar } from '@libp2p/interface-internal'
22
+ *
23
+ * const registrar: Registrar
24
+ *
25
+ * registrar.register('/my/protocol/1.0.0', {
26
+ * filter: peerFilter(),
27
+ * onConnect: (peerId) => {
28
+ * // will only be invoked for a given peerId once
29
+ * }
30
+ * })
31
+ * ```
15
32
  *
16
33
  * @param size - The maximum number of peers expected to be added to the filter
17
34
  * @param errorRate - The acceptable error rate
@@ -1 +1 @@
1
- {"version":3,"file":"filter.d.ts","sourceRoot":"","sources":["../../src/filter.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAG/C;;;GAGG;AACH,qBAAa,UAAU;IACrB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAQ;gBAElB,IAAI,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM;IAI7C,GAAG,CAAE,MAAM,EAAE,MAAM,GAAG,OAAO;IAI7B,GAAG,CAAE,MAAM,EAAE,MAAM,GAAG,IAAI;IAI1B,MAAM,CAAE,MAAM,EAAE,MAAM,GAAG,IAAI;CAG9B;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAE,IAAI,EAAE,MAAM,EAAE,SAAS,GAAE,MAAc,GAAG,UAAU,CAE/E"}
1
+ {"version":3,"file":"filter.d.ts","sourceRoot":"","sources":["../../src/filter.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAG/C;;;GAGG;AACH,qBAAa,UAAU;IACrB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAQ;gBAElB,IAAI,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM;IAI7C,GAAG,CAAE,MAAM,EAAE,MAAM,GAAG,OAAO;IAI7B,GAAG,CAAE,MAAM,EAAE,MAAM,GAAG,IAAI;IAI1B,MAAM,CAAE,MAAM,EAAE,MAAM,GAAG,IAAI;CAG9B;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,UAAU,CAAE,IAAI,EAAE,MAAM,EAAE,SAAS,GAAE,MAAc,GAAG,UAAU,CAE/E"}
@@ -19,7 +19,24 @@ export class PeerFilter {
19
19
  }
20
20
  }
21
21
  /**
22
- * Create and return a PeerFilter
22
+ * Create and return a PeerFilter. This can be used by topologies to prevent
23
+ * them receiving duplicate notifications for a peer that connects repeatedly.
24
+ *
25
+ * @example
26
+ *
27
+ * ```TypeScript
28
+ * import { peerFilter } from '@libp2p/peer-collections'
29
+ * import type { Registrar } from '@libp2p/interface-internal'
30
+ *
31
+ * const registrar: Registrar
32
+ *
33
+ * registrar.register('/my/protocol/1.0.0', {
34
+ * filter: peerFilter(),
35
+ * onConnect: (peerId) => {
36
+ * // will only be invoked for a given peerId once
37
+ * }
38
+ * })
39
+ * ```
23
40
  *
24
41
  * @param size - The maximum number of peers expected to be added to the filter
25
42
  * @param errorRate - The acceptable error rate
@@ -1 +1 @@
1
- {"version":3,"file":"filter.js","sourceRoot":"","sources":["../../src/filter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAA;AAIlE;;;GAGG;AACH,MAAM,OAAO,UAAU;IACJ,MAAM,CAAQ;IAE/B,YAAa,IAAY,EAAE,SAAkB;QAC3C,IAAI,CAAC,MAAM,GAAG,0BAA0B,CAAC,IAAI,EAAE,SAAS,CAAC,C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ClD,CAAC;CACF;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,UAAU,UAAU,CAAE,IAAY,EAAE,YAAoB,KAAK;IACjE,OAAO,IAAI,UAAU,CAAC,IAAI,EAAE,SAAS,CAAC,CAAA;AACxC,CAAC"}
@@ -9,7 +9,7 @@ export interface TrackedPeerListInit {
9
9
  *
10
10
  * @example
11
11
  *
12
- * * ```Typescript
12
+ * ```Typescript
13
13
  * import { trackedPeerList } from '@libp2p/peer-collections'
14
14
  * import { createLibp2p } from 'libp2p'
15
15
  *
@@ -39,7 +39,7 @@ class TrackedPeerList extends PeerList {
39
39
  *
40
40
  * @example
41
41
  *
42
- * * ```Typescript
42
+ * ```Typescript
43
43
  * import { trackedPeerList } from '@libp2p/peer-collections'
44
44
  * import { createLibp2p } from 'libp2p'
45
45
  *
@@ -9,7 +9,7 @@ export interface TrackedPeerMapInit {
9
9
  *
10
10
  * @example
11
11
  *
12
- * * ```Typescript
12
+ * ```Typescript
13
13
  * import { trackedPeerMap } from '@libp2p/peer-collections'
14
14
  * import { createLibp2p } from 'libp2p'
15
15
  *
@@ -30,7 +30,7 @@ class TrackedPeerMap extends PeerMap {
30
30
  *
31
31
  * @example
32
32
  *
33
- * * ```Typescript
33
+ * ```Typescript
34
34
  * import { trackedPeerMap } from '@libp2p/peer-collections'
35
35
  * import { createLibp2p } from 'libp2p'
36
36
  *
@@ -9,7 +9,7 @@ export interface TrackedPeerSetInit {
9
9
  *
10
10
  * @example Tracked peer sets
11
11
  *
12
- * * ```Typescript
12
+ * ```Typescript
13
13
  * import { trackedPeerSet } from '@libp2p/peer-collections'
14
14
  * import { createLibp2p } from 'libp2p'
15
15
  *
@@ -28,7 +28,7 @@ class TrackedPeerSet extends PeerSet {
28
28
  *
29
29
  * @example Tracked peer sets
30
30
  *
31
- * * ```Typescript
31
+ * ```Typescript
32
32
  * import { trackedPeerSet } from '@libp2p/peer-collections'
33
33
  * import { createLibp2p } from 'libp2p'
34
34
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@libp2p/peer-collections",
3
- "version": "6.0.27",
3
+ "version": "6.0.28-aa25d38ab",
4
4
  "description": "Stores values against a peer id",
5
5
  "license": "Apache-2.0 OR MIT",
6
6
  "homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/peer-collections#readme",
@@ -32,13 +32,6 @@
32
32
  "import": "./dist/src/index.js"
33
33
  }
34
34
  },
35
- "eslintConfig": {
36
- "extends": "ipfs",
37
- "parserOptions": {
38
- "project": true,
39
- "sourceType": "module"
40
- }
41
- },
42
35
  "scripts": {
43
36
  "clean": "aegir clean",
44
37
  "lint": "aegir lint",
@@ -54,16 +47,16 @@
54
47
  "test:electron-main": "aegir test -t electron-main"
55
48
  },
56
49
  "dependencies": {
57
- "@libp2p/interface": "^2.9.0",
58
- "@libp2p/peer-id": "^5.1.2",
59
- "@libp2p/utils": "^6.6.2",
60
- "multiformats": "^13.3.1"
50
+ "@libp2p/interface": "2.10.0-aa25d38ab",
51
+ "@libp2p/peer-id": "5.1.3-aa25d38ab",
52
+ "@libp2p/utils": "6.6.3-aa25d38ab",
53
+ "multiformats": "^13.3.4"
61
54
  },
62
55
  "devDependencies": {
63
- "@libp2p/crypto": "^5.1.1",
64
- "@types/sinon": "^17.0.3",
65
- "aegir": "^45.1.1",
66
- "sinon": "^19.0.2",
56
+ "@libp2p/crypto": "5.1.2-aa25d38ab",
57
+ "@types/sinon": "^17.0.4",
58
+ "aegir": "^47.0.6",
59
+ "sinon": "^20.0.0",
67
60
  "sinon-ts": "^2.0.0"
68
61
  },
69
62
  "sideEffects": false
package/src/filter.ts CHANGED
@@ -27,7 +27,24 @@ export class PeerFilter {
27
27
  }
28
28
 
29
29
  /**
30
- * Create and return a PeerFilter
30
+ * Create and return a PeerFilter. This can be used by topologies to prevent
31
+ * them receiving duplicate notifications for a peer that connects repeatedly.
32
+ *
33
+ * @example
34
+ *
35
+ * ```TypeScript
36
+ * import { peerFilter } from '@libp2p/peer-collections'
37
+ * import type { Registrar } from '@libp2p/interface-internal'
38
+ *
39
+ * const registrar: Registrar
40
+ *
41
+ * registrar.register('/my/protocol/1.0.0', {
42
+ * filter: peerFilter(),
43
+ * onConnect: (peerId) => {
44
+ * // will only be invoked for a given peerId once
45
+ * }
46
+ * })
47
+ * ```
31
48
  *
32
49
  * @param size - The maximum number of peers expected to be added to the filter
33
50
  * @param errorRate - The acceptable error rate
@@ -56,7 +56,7 @@ class TrackedPeerList extends PeerList {
56
56
  *
57
57
  * @example
58
58
  *
59
- * * ```Typescript
59
+ * ```Typescript
60
60
  * import { trackedPeerList } from '@libp2p/peer-collections'
61
61
  * import { createLibp2p } from 'libp2p'
62
62
  *
@@ -45,7 +45,7 @@ class TrackedPeerMap<V> extends PeerMap<V> {
45
45
  *
46
46
  * @example
47
47
  *
48
- * * ```Typescript
48
+ * ```Typescript
49
49
  * import { trackedPeerMap } from '@libp2p/peer-collections'
50
50
  * import { createLibp2p } from 'libp2p'
51
51
  *
@@ -43,7 +43,7 @@ class TrackedPeerSet extends PeerSet {
43
43
  *
44
44
  * @example Tracked peer sets
45
45
  *
46
- * * ```Typescript
46
+ * ```Typescript
47
47
  * import { trackedPeerSet } from '@libp2p/peer-collections'
48
48
  * import { createLibp2p } from 'libp2p'
49
49
  *
@@ -1,16 +0,0 @@
1
- {
2
- "PeerFilter": "https://libp2p.github.io/js-libp2p/classes/_libp2p_peer_collections.PeerFilter.html",
3
- "PeerList": "https://libp2p.github.io/js-libp2p/classes/_libp2p_peer_collections.PeerList.html",
4
- "PeerMap": "https://libp2p.github.io/js-libp2p/classes/_libp2p_peer_collections.PeerMap.html",
5
- "PeerSet": "https://libp2p.github.io/js-libp2p/classes/_libp2p_peer_collections.PeerSet.html",
6
- "TrackedPeerListInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_peer_collections.TrackedPeerListInit.html",
7
- "TrackedPeerMapInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_peer_collections.TrackedPeerMapInit.html",
8
- "TrackedPeerSetInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_peer_collections.TrackedPeerSetInit.html",
9
- "peerFilter": "https://libp2p.github.io/js-libp2p/functions/_libp2p_peer_collections.peerFilter-1.html",
10
- "peerList": "https://libp2p.github.io/js-libp2p/functions/_libp2p_peer_collections.peerList-1.html",
11
- "peerMap": "https://libp2p.github.io/js-libp2p/functions/_libp2p_peer_collections.peerMap-1.html",
12
- "peerSet": "https://libp2p.github.io/js-libp2p/functions/_libp2p_peer_collections.peerSet-1.html",
13
- "trackedPeerList": "https://libp2p.github.io/js-libp2p/functions/_libp2p_peer_collections.trackedPeerList.html",
14
- "trackedPeerMap": "https://libp2p.github.io/js-libp2p/functions/_libp2p_peer_collections.trackedPeerMap.html",
15
- "trackedPeerSet": "https://libp2p.github.io/js-libp2p/functions/_libp2p_peer_collections.trackedPeerSet.html"
16
- }