@libp2p/interface 1.3.1 → 1.4.0

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.
@@ -1,9 +1,33 @@
1
1
  import type { Connection } from '../connection/index.js';
2
2
  import type { PeerId } from '../peer-id/index.js';
3
+ /**
4
+ * A topology filter
5
+ *
6
+ * @see https://libp2p.github.io/js-libp2p/functions/_libp2p_peer_collections.peerFilter-1.html
7
+ */
8
+ export interface TopologyFilter {
9
+ has(peerId: PeerId): boolean;
10
+ add(peerId: PeerId): void;
11
+ remove(peerId: PeerId): void;
12
+ }
13
+ /**
14
+ * A topology is a network overlay that contains a subset of peers in the
15
+ * complete network.
16
+ *
17
+ * It is a way to be notified when peers that support a given protocol connect
18
+ * to or disconnect from the current node.
19
+ */
3
20
  export interface Topology {
21
+ /**
22
+ * An optional filter can prevent duplicate topology notifications for the
23
+ * same peer.
24
+ */
25
+ filter?: TopologyFilter;
4
26
  /**
5
27
  * If true, invoke `onConnect` for this topology on transient (e.g. short-lived
6
- * and/or data-limited) connections. (default: false)
28
+ * and/or data-limited) connections
29
+ *
30
+ * @default false
7
31
  */
8
32
  notifyOnTransient?: boolean;
9
33
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/topology/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AACxD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAEjD,MAAM,WAAW,QAAQ;IACvB;;;OAGG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAE3B;;;OAGG;IACH,SAAS,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,GAAG,IAAI,CAAA;IAElD;;;OAGG;IACH,YAAY,CAAC,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;CACpC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/topology/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AACxD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAEjD;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B,GAAG,CAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAA;IAC7B,GAAG,CAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;IAC1B,MAAM,CAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;CAC9B;AAED;;;;;;GAMG;AACH,MAAM,WAAW,QAAQ;IACvB;;;OAGG;IACH,MAAM,CAAC,EAAE,cAAc,CAAA;IAEvB;;;;;OAKG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAE3B;;;OAGG;IACH,SAAS,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,GAAG,IAAI,CAAA;IAElD;;;OAGG;IACH,YAAY,CAAC,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;CACpC"}
@@ -110,6 +110,7 @@
110
110
  "TagOptions": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.TagOptions.html",
111
111
  "TopicValidatorFn": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.TopicValidatorFn.html",
112
112
  "Topology": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.Topology.html",
113
+ "TopologyFilter": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.TopologyFilter.html",
113
114
  "Transport": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.Transport.html",
114
115
  "TypedEventTarget": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.TypedEventTarget.html",
115
116
  "UnsignedMessage": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.UnsignedMessage.html",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@libp2p/interface",
3
- "version": "1.3.1",
3
+ "version": "1.4.0",
4
4
  "description": "The interface implemented by a libp2p node",
5
5
  "license": "Apache-2.0 OR MIT",
6
6
  "homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/interface#readme",
@@ -48,7 +48,7 @@
48
48
  "build": "aegir build"
49
49
  },
50
50
  "dependencies": {
51
- "@multiformats/multiaddr": "^12.2.1",
51
+ "@multiformats/multiaddr": "^12.2.3",
52
52
  "it-pushable": "^3.2.3",
53
53
  "it-stream-types": "^2.0.1",
54
54
  "multiformats": "^13.1.0",
@@ -56,7 +56,7 @@
56
56
  "uint8arraylist": "^2.4.8"
57
57
  },
58
58
  "devDependencies": {
59
- "aegir": "^42.2.5"
59
+ "aegir": "^42.2.11"
60
60
  },
61
61
  "browser": {
62
62
  "events": "./dist/src/events.browser.js"
@@ -1,10 +1,36 @@
1
1
  import type { Connection } from '../connection/index.js'
2
2
  import type { PeerId } from '../peer-id/index.js'
3
3
 
4
+ /**
5
+ * A topology filter
6
+ *
7
+ * @see https://libp2p.github.io/js-libp2p/functions/_libp2p_peer_collections.peerFilter-1.html
8
+ */
9
+ export interface TopologyFilter {
10
+ has (peerId: PeerId): boolean
11
+ add (peerId: PeerId): void
12
+ remove (peerId: PeerId): void
13
+ }
14
+
15
+ /**
16
+ * A topology is a network overlay that contains a subset of peers in the
17
+ * complete network.
18
+ *
19
+ * It is a way to be notified when peers that support a given protocol connect
20
+ * to or disconnect from the current node.
21
+ */
4
22
  export interface Topology {
23
+ /**
24
+ * An optional filter can prevent duplicate topology notifications for the
25
+ * same peer.
26
+ */
27
+ filter?: TopologyFilter
28
+
5
29
  /**
6
30
  * If true, invoke `onConnect` for this topology on transient (e.g. short-lived
7
- * and/or data-limited) connections. (default: false)
31
+ * and/or data-limited) connections
32
+ *
33
+ * @default false
8
34
  */
9
35
  notifyOnTransient?: boolean
10
36