@waku/core 0.0.33-b93134a.0 → 0.0.33-c9fdfb3.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.
@@ -14,4 +14,6 @@ export declare class StreamManager {
14
14
  private handlePeerUpdateStreamPool;
15
15
  private scheduleNewStream;
16
16
  private getOpenStreamForCodec;
17
+ private lockStream;
18
+ private isStreamLocked;
17
19
  }
@@ -1,5 +1,6 @@
1
1
  import { Logger } from "@waku/utils";
2
2
  import { selectOpenConnection } from "./utils.js";
3
+ const STREAM_LOCK_KEY = "consumed";
3
4
  export class StreamManager {
4
5
  multicodec;
5
6
  getConnections;
@@ -21,12 +22,15 @@ export class StreamManager {
21
22
  this.streamPool.delete(peerId);
22
23
  await scheduledStream;
23
24
  }
24
- const stream = this.getOpenStreamForCodec(peer.id);
25
+ let stream = this.getOpenStreamForCodec(peer.id);
25
26
  if (stream) {
26
27
  this.log.info(`Found existing stream peerId=${peer.id.toString()} multicodec=${this.multicodec}`);
28
+ this.lockStream(peer.id.toString(), stream);
27
29
  return stream;
28
30
  }
29
- return this.createStream(peer);
31
+ stream = await this.createStream(peer);
32
+ this.lockStream(peer.id.toString(), stream);
33
+ return stream;
30
34
  }
31
35
  async createStream(peer, retries = 0) {
32
36
  const connections = this.getConnections(peer.id);
@@ -97,11 +101,21 @@ export class StreamManager {
97
101
  return;
98
102
  }
99
103
  const stream = connection.streams.find((s) => s.protocol === this.multicodec);
100
- const isStreamUnusable = ["done", "closed", "closing"].includes(stream?.writeStatus || "");
101
- if (isStreamUnusable) {
104
+ if (!stream) {
105
+ return;
106
+ }
107
+ const isStreamUnusable = ["done", "closed", "closing"].includes(stream.writeStatus || "");
108
+ if (isStreamUnusable || this.isStreamLocked(stream)) {
102
109
  return;
103
110
  }
104
111
  return stream;
105
112
  }
113
+ lockStream(peerId, stream) {
114
+ this.log.info(`Locking stream for peerId:${peerId}\tstreamId:${stream.id}`);
115
+ stream.metadata[STREAM_LOCK_KEY] = true;
116
+ }
117
+ isStreamLocked(stream) {
118
+ return !!stream.metadata[STREAM_LOCK_KEY];
119
+ }
106
120
  }
107
121
  //# sourceMappingURL=stream_manager.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"stream_manager.js","sourceRoot":"","sources":["../../../src/lib/stream_manager/stream_manager.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAElD,MAAM,OAAO,aAAa;IAOd;IACA;IACA;IARO,GAAG,CAAS;IAErB,eAAe,GAAgB,IAAI,GAAG,EAAE,CAAC;IACzC,UAAU,GAA+B,IAAI,GAAG,EAAE,CAAC;IAE3D,YACU,UAAkB,EAClB,cAAwC,EACxC,gBAA4C;QAF5C,eAAU,GAAV,UAAU,CAAQ;QAClB,mBAAc,GAAd,cAAc,CAA0B;QACxC,qBAAgB,GAAhB,gBAAgB,CAA4B;QAEpD,IAAI,CAAC,GAAG,GAAG,IAAI,MAAM,CAAC,kBAAkB,UAAU,EAAE,CAAC,CAAC;QACtD,IAAI,CAAC,gBAAgB,CAAC,aAAa,EAAE,IAAI,CAAC,0BAA0B,CAAC,CAAC;IACxE,CAAC;IAEM,KAAK,CAAC,SAAS,CAAC,IAAU;QAC/B,MAAM,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAC;QAElC,MAAM,eAAe,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QAEpD,IAAI,eAAe,EAAE,CAAC;YACpB,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;YAC/B,MAAM,eAAe,CAAC;QACxB,CAAC;QAED,MAAM,MAAM,GAAG,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAEnD,IAAI,MAAM,EAAE,CAAC;YACX,IAAI,CAAC,GAAG,CAAC,I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AAC,GAAG,CAAC,IAAI,CAAC,6BAA6B,MAAM,cAAc,MAAM,CAAC,EAAE,EAAE,CAAC,CAAC;QAC5E,MAAM,CAAC,QAAQ,CAAC,eAAe,CAAC,GAAG,IAAI,CAAC;IAC1C,CAAC;IAEO,cAAc,CAAC,MAAc;QACnC,OAAO,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC;IAC5C,CAAC;CACF"}
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name":"@waku/core","version":"0.0.33-b93134a.0","description":"TypeScript implementation of the Waku v2 protocol","types":"./dist/index.d.ts","module":"./dist/index.js","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"},"./lib/message/version_0":{"types":"./dist/lib/message/version_0.d.ts","import":"./dist/lib/message/version_0.js"},"./lib/base_protocol":{"types":"./dist/lib/base_protocol.d.ts","import":"./dist/lib/base_protocol.js"}},"typesVersions":{"*":{"lib/*":["dist/lib/*"],"constants/*":["dist/constants/*"]}},"type":"module","homepage":"https://github.com/waku-org/js-waku/tree/master/packages/core#readme","repository":{"type":"git","url":"https://github.com/waku-org/js-waku.git"},"bugs":{"url":"https://github.com/waku-org/js-waku/issues"},"license":"MIT OR Apache-2.0","keywords":["waku","decentralised","communication","web3","ethereum","dapps"],"scripts":{"build":"run-s build:**","build:esm":"tsc","build:bundle":"rollup --config rollup.config.js","fix":"run-s fix:*","fix:lint":"eslint src *.js --fix","check":"run-s check:*","check:tsc":"tsc -p tsconfig.dev.json","check:lint":"eslint src *.js","check:spelling":"cspell \"{README.md,src/**/*.ts}\"","test":"NODE_ENV=test run-s test:*","test:node":"NODE_ENV=test TS_NODE_PROJECT=./tsconfig.dev.json mocha","test:browser":"NODE_ENV=test karma start karma.conf.cjs","watch:build":"tsc -p tsconfig.json -w","watch:test":"mocha --watch","prepublish":"npm run build","reset-hard":"git clean -dfx -e .idea && git reset --hard && npm i && npm run build"},"engines":{"node":">=20"},"dependencies":{"@libp2p/ping":"^1.1.2","@waku/enr":"0.0.27-b93134a.0","@waku/interfaces":"0.0.28-b93134a.0","@waku/proto":"0.0.9-b93134a.0","@waku/utils":"0.0.21-b93134a.0","debug":"^4.3.4","it-all":"^3.0.4","it-length-prefixed":"^9.0.4","it-pipe":"^3.0.1","p-event":"^6.0.1","uint8arraylist":"^2.4.3","uuid":"^9.0.0"},"devDependencies":{"@multiformats/multiaddr":"^12.0.0","@rollup/plugin-commonjs":"^25.0.7","@rollup/plugin-json":"^6.0.0","@rollup/plugin-node-resolve":"^15.2.3","@types/chai":"^4.3.11","@types/debug":"^4.1.12","@types/mocha":"^10.0.6","@types/uuid":"^9.0.8","@waku/build-utils":"*","chai":"^4.3.10","sinon":"^18.0.0","cspell":"^8.6.1","fast-check":"^3.19.0","ignore-loader":"^0.1.2","isomorphic-fetch":"^3.0.0","mocha":"^10.3.0","npm-run-all":"^4.1.5","process":"^0.11.10","rollup":"^4.12.0"},"peerDependencies":{"@multiformats/multiaddr":"^12.0.0","libp2p":"^1.8.1"},"peerDependenciesMeta":{"@multiformats/multiaddr":{"optional":true},"libp2p":{"optional":true}},"files":["dist","bundle","src/**/*.ts","!**/*.spec.*","!**/*.json","CHANGELOG.md","LICENSE","README.md"]}
1
+ {"name":"@waku/core","version":"0.0.33-c9fdfb3.0","description":"TypeScript implementation of the Waku v2 protocol","types":"./dist/index.d.ts","module":"./dist/index.js","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"},"./lib/message/version_0":{"types":"./dist/lib/message/version_0.d.ts","import":"./dist/lib/message/version_0.js"},"./lib/base_protocol":{"types":"./dist/lib/base_protocol.d.ts","import":"./dist/lib/base_protocol.js"}},"typesVersions":{"*":{"lib/*":["dist/lib/*"],"constants/*":["dist/constants/*"]}},"type":"module","homepage":"https://github.com/waku-org/js-waku/tree/master/packages/core#readme","repository":{"type":"git","url":"https://github.com/waku-org/js-waku.git"},"bugs":{"url":"https://github.com/waku-org/js-waku/issues"},"license":"MIT OR Apache-2.0","keywords":["waku","decentralised","communication","web3","ethereum","dapps"],"scripts":{"build":"run-s build:**","build:esm":"tsc","build:bundle":"rollup --config rollup.config.js","fix":"run-s fix:*","fix:lint":"eslint src *.js --fix","check":"run-s check:*","check:tsc":"tsc -p tsconfig.dev.json","check:lint":"eslint src *.js","check:spelling":"cspell \"{README.md,src/**/*.ts}\"","test":"NODE_ENV=test run-s test:*","test:node":"NODE_ENV=test TS_NODE_PROJECT=./tsconfig.dev.json mocha","test:browser":"NODE_ENV=test karma start karma.conf.cjs","watch:build":"tsc -p tsconfig.json -w","watch:test":"mocha --watch","prepublish":"npm run build","reset-hard":"git clean -dfx -e .idea && git reset --hard && npm i && npm run build"},"engines":{"node":">=20"},"dependencies":{"@libp2p/ping":"^1.1.2","@waku/enr":"0.0.27-c9fdfb3.0","@waku/interfaces":"0.0.28-c9fdfb3.0","@waku/proto":"0.0.9-c9fdfb3.0","@waku/utils":"0.0.21-c9fdfb3.0","debug":"^4.3.4","it-all":"^3.0.4","it-length-prefixed":"^9.0.4","it-pipe":"^3.0.1","uint8arraylist":"^2.4.3","uuid":"^9.0.0"},"devDependencies":{"@multiformats/multiaddr":"^12.0.0","@rollup/plugin-commonjs":"^25.0.7","@rollup/plugin-json":"^6.0.0","@rollup/plugin-node-resolve":"^15.2.3","@types/chai":"^4.3.11","@types/debug":"^4.1.12","@types/mocha":"^10.0.6","@types/uuid":"^9.0.8","@waku/build-utils":"*","chai":"^4.3.10","sinon":"^18.0.0","cspell":"^8.6.1","fast-check":"^3.19.0","ignore-loader":"^0.1.2","isomorphic-fetch":"^3.0.0","mocha":"^10.3.0","npm-run-all":"^4.1.5","process":"^0.11.10","rollup":"^4.12.0"},"peerDependencies":{"@multiformats/multiaddr":"^12.0.0","libp2p":"^1.8.1"},"peerDependenciesMeta":{"@multiformats/multiaddr":{"optional":true},"libp2p":{"optional":true}},"files":["dist","bundle","src/**/*.ts","!**/*.spec.*","!**/*.json","CHANGELOG.md","LICENSE","README.md"]}
package/src/index.ts CHANGED
@@ -13,9 +13,7 @@ export * as waku_light_push from "./lib/light_push/index.js";
13
13
  export { LightPushCodec, LightPushCore } from "./lib/light_push/index.js";
14
14
 
15
15
  export * as waku_store from "./lib/store/index.js";
16
- export { StoreCore } from "./lib/store/index.js";
17
-
18
- export { waitForRemotePeer } from "./lib/wait_for_remote_peer.js";
16
+ export { StoreCore, StoreCodec } from "./lib/store/index.js";
19
17
 
20
18
  export { ConnectionManager } from "./lib/connection_manager.js";
21
19
 
@@ -1,16 +1,12 @@
1
1
  import type { Libp2p } from "@libp2p/interface";
2
- import type { Peer, PeerStore, Stream } from "@libp2p/interface";
2
+ import type { Peer, Stream } from "@libp2p/interface";
3
3
  import type {
4
4
  IBaseProtocolCore,
5
5
  Libp2pComponents,
6
6
  PubsubTopic
7
7
  } from "@waku/interfaces";
8
- import { Logger, pubsubTopicsToShardInfo } from "@waku/utils";
9
- import {
10
- getConnectedPeersForProtocolAndShard,
11
- getPeersForProtocol,
12
- sortPeersByLatency
13
- } from "@waku/utils/libp2p";
8
+ import { Logger } from "@waku/utils";
9
+ import { getPeersForProtocol, sortPeersByLatency } from "@waku/utils/libp2p";
14
10
 
15
11
  import { filterPeersByDiscovery } from "./filterPeers.js";
16
12
  import { StreamManager } from "./stream_manager/index.js";
@@ -26,7 +22,7 @@ export class BaseProtocol implements IBaseProtocolCore {
26
22
 
27
23
  protected constructor(
28
24
  public multicodec: string,
29
- private components: Libp2pComponents,
25
+ protected components: Libp2pComponents,
30
26
  private log: Logger,
31
27
  public readonly pubsubTopics: PubsubTopic[]
32
28
  ) {
@@ -50,25 +46,22 @@ export class BaseProtocol implements IBaseProtocolCore {
50
46
  return this.streamManager.getStream(peer);
51
47
  }
52
48
 
53
- public get peerStore(): PeerStore {
54
- return this.components.peerStore;
55
- }
56
-
57
49
  /**
58
50
  * Returns known peers from the address book (`libp2p.peerStore`) that support
59
51
  * the class protocol. Waku may or may not be currently connected to these
60
52
  * peers.
61
53
  */
62
54
  public async allPeers(): Promise<Peer[]> {
63
- return getPeersForProtocol(this.peerStore, [this.multicodec]);
55
+ return getPeersForProtocol(this.components.peerStore, [this.multicodec]);
64
56
  }
65
57
 
66
58
  public async connectedPeers(): Promise<Peer[]> {
67
59
  const peers = await this.allPeers();
68
60
  return peers.filter((peer) => {
69
- return (
70
- this.components.connectionManager.getConnections(peer.id).length > 0
61
+ const connections = this.components.connectionManager.getConnections(
62
+ peer.id
71
63
  );
64
+ return connections.length > 0;
72
65
  });
73
66
  }
74
67
 
@@ -77,9 +70,8 @@ export class BaseProtocol implements IBaseProtocolCore {
77
70
  *
78
71
  * @param numPeers - The total number of peers to retrieve. If 0, all peers are returned.
79
72
  * @param maxBootstrapPeers - The maximum number of bootstrap peers to retrieve.
80
-
81
- * @returns A list of peers that support the protocol sorted by latency.
82
- */
73
+ * @returns A list of peers that support the protocol sorted by latency. By default, returns all peers available, including bootstrap.
74
+ */
83
75
  public async getPeers(
84
76
  {
85
77
  numPeers,
@@ -88,29 +80,23 @@ export class BaseProtocol implements IBaseProtocolCore {
88
80
  numPeers: number;
89
81
  maxBootstrapPeers: number;
90
82
  } = {
91
- maxBootstrapPeers: 1,
83
+ maxBootstrapPeers: 0,
92
84
  numPeers: 0
93
85
  }
94
86
  ): Promise<Peer[]> {
95
87
  // Retrieve all connected peers that support the protocol & shard (if configured)
96
- const connectedPeersForProtocolAndShard =
97
- await getConnectedPeersForProtocolAndShard(
98
- this.components.connectionManager.getConnections(),
99
- this.peerStore,
100
- [this.multicodec],
101
- pubsubTopicsToShardInfo(this.pubsubTopics)
102
- );
88
+ const allAvailableConnectedPeers = await this.connectedPeers();
103
89
 
104
90
  // Filter the peers based on discovery & number of peers requested
105
91
  const filteredPeers = filterPeersByDiscovery(
106
- connectedPeersForProtocolAndShard,
92
+ allAvailableConnectedPeers,
107
93
  numPeers,
108
94
  maxBootstrapPeers
109
95
  );
110
96
 
111
97
  // Sort the peers by latency
112
98
  const sortedFilteredPeers = await sortPeersByLatency(
113
- this.peerStore,
99
+ this.components.peerStore,
114
100
  filteredPeers
115
101
  );
116
102
 
@@ -301,8 +301,17 @@ export class FilterCore extends BaseProtocol implements IBaseProtocolCore {
301
301
  () => {
302
302
  log.info("Receiving pipe closed.");
303
303
  },
304
- (e) => {
305
- log.error("Error with receiving pipe", e);
304
+ async (e) => {
305
+ log.error(
306
+ "Error with receiving pipe",
307
+ e,
308
+ " -- ",
309
+ "on peer ",
310
+ connection.remotePeer.toString(),
311
+ " -- ",
312
+ "stream ",
313
+ stream
314
+ );
306
315
  }
307
316
  );
308
317
  } catch (e) {
@@ -45,7 +45,7 @@ class Metadata extends BaseProtocol implements IMetadata {
45
45
  pubsubTopicsToShardInfo(this.pubsubTopics)
46
46
  );
47
47
 
48
- const peer = await this.peerStore.get(peerId);
48
+ const peer = await this.libp2pComponents.peerStore.get(peerId);
49
49
  if (!peer) {
50
50
  return {
51
51
  shardInfo: null,
@@ -4,6 +4,8 @@ import { Logger } from "@waku/utils";
4
4
 
5
5
  import { selectOpenConnection } from "./utils.js";
6
6
 
7
+ const STREAM_LOCK_KEY = "consumed";
8
+
7
9
  export class StreamManager {
8
10
  private readonly log: Logger;
9
11
 
@@ -29,16 +31,20 @@ export class StreamManager {
29
31
  await scheduledStream;
30
32
  }
31
33
 
32
- const stream = this.getOpenStreamForCodec(peer.id);
34
+ let stream = this.getOpenStreamForCodec(peer.id);
33
35
 
34
36
  if (stream) {
35
37
  this.log.info(
36
38
  `Found existing stream peerId=${peer.id.toString()} multicodec=${this.multicodec}`
37
39
  );
40
+ this.lockStream(peer.id.toString(), stream);
38
41
  return stream;
39
42
  }
40
43
 
41
- return this.createStream(peer);
44
+ stream = await this.createStream(peer);
45
+ this.lockStream(peer.id.toString(), stream);
46
+
47
+ return stream;
42
48
  }
43
49
 
44
50
  private async createStream(peer: Peer, retries = 0): Promise<Stream> {
@@ -142,13 +148,26 @@ export class StreamManager {
142
148
  (s) => s.protocol === this.multicodec
143
149
  );
144
150
 
151
+ if (!stream) {
152
+ return;
153
+ }
154
+
145
155
  const isStreamUnusable = ["done", "closed", "closing"].includes(
146
- stream?.writeStatus || ""
156
+ stream.writeStatus || ""
147
157
  );
148
- if (isStreamUnusable) {
158
+ if (isStreamUnusable || this.isStreamLocked(stream)) {
149
159
  return;
150
160
  }
151
161
 
152
162
  return stream;
153
163
  }
164
+
165
+ private lockStream(peerId: string, stream: Stream): void {
166
+ this.log.info(`Locking stream for peerId:${peerId}\tstreamId:${stream.id}`);
167
+ stream.metadata[STREAM_LOCK_KEY] = true;
168
+ }
169
+
170
+ private isStreamLocked(stream: Stream): boolean {
171
+ return !!stream.metadata[STREAM_LOCK_KEY];
172
+ }
154
173
  }
@@ -1,22 +0,0 @@
1
- import type { Waku } from "@waku/interfaces";
2
- import { Protocols } from "@waku/interfaces";
3
- /**
4
- * Wait for a remote peer to be ready given the passed protocols.
5
- * Must be used after attempting to connect to nodes, using
6
- * {@link @waku/sdk!WakuNode.dial} or a bootstrap method with
7
- * {@link @waku/sdk!createLightNode}.
8
- *
9
- * If the passed protocols is a GossipSub protocol, then it resolves only once
10
- * a peer is in a mesh, to help ensure that other peers will send and receive
11
- * message to us.
12
- *
13
- * @param waku The Waku Node
14
- * @param protocols The protocols that need to be enabled by remote peers.
15
- * @param timeoutMs A timeout value in milliseconds..
16
- *
17
- * @returns A promise that **resolves** if all desired protocols are fulfilled by
18
- * remote nodes, **rejects** if the timeoutMs is reached.
19
- * @throws If passing a protocol that is not mounted
20
- * @default Wait for remote peers with protocols enabled locally and no time out is applied.
21
- */
22
- export declare function waitForRemotePeer(waku: Waku, protocols?: Protocols[], timeoutMs?: number): Promise<void>;
@@ -1,142 +0,0 @@
1
- import { Protocols } from "@waku/interfaces";
2
- import { Logger } from "@waku/utils";
3
- import { pEvent } from "p-event";
4
- const log = new Logger("wait-for-remote-peer");
5
- //TODO: move this function within the Waku class: https://github.com/waku-org/js-waku/issues/1761
6
- /**
7
- * Wait for a remote peer to be ready given the passed protocols.
8
- * Must be used after attempting to connect to nodes, using
9
- * {@link @waku/sdk!WakuNode.dial} or a bootstrap method with
10
- * {@link @waku/sdk!createLightNode}.
11
- *
12
- * If the passed protocols is a GossipSub protocol, then it resolves only once
13
- * a peer is in a mesh, to help ensure that other peers will send and receive
14
- * message to us.
15
- *
16
- * @param waku The Waku Node
17
- * @param protocols The protocols that need to be enabled by remote peers.
18
- * @param timeoutMs A timeout value in milliseconds..
19
- *
20
- * @returns A promise that **resolves** if all desired protocols are fulfilled by
21
- * remote nodes, **rejects** if the timeoutMs is reached.
22
- * @throws If passing a protocol that is not mounted
23
- * @default Wait for remote peers with protocols enabled locally and no time out is applied.
24
- */
25
- export async function waitForRemotePeer(waku, protocols, timeoutMs) {
26
- protocols = protocols ?? getEnabledProtocols(waku);
27
- if (!waku.isStarted())
28
- return Promise.reject("Waku node is not started");
29
- const promises = [];
30
- if (protocols.includes(Protocols.Relay)) {
31
- if (!waku.relay)
32
- throw new Error("Cannot wait for Relay peer: protocol not mounted");
33
- promises.push(waitForGossipSubPeerInMesh(waku.relay));
34
- }
35
- if (protocols.includes(Protocols.Store)) {
36
- if (!waku.store)
37
- throw new Error("Cannot wait for Store peer: protocol not mounted");
38
- promises.push(waitForConnectedPeer(waku.store.protocol, waku.libp2p.services.metadata));
39
- }
40
- if (protocols.includes(Protocols.LightPush)) {
41
- if (!waku.lightPush)
42
- throw new Error("Cannot wait for LightPush peer: protocol not mounted");
43
- promises.push(waitForConnectedPeer(waku.lightPush.protocol, waku.libp2p.services.metadata));
44
- }
45
- if (protocols.includes(Protocols.Filter)) {
46
- if (!waku.filter)
47
- throw new Error("Cannot wait for Filter peer: protocol not mounted");
48
- promises.push(waitForConnectedPeer(waku.filter.protocol, waku.libp2p.services.metadata));
49
- }
50
- if (timeoutMs) {
51
- await rejectOnTimeout(Promise.all(promises), timeoutMs, "Timed out waiting for a remote peer.");
52
- }
53
- else {
54
- await Promise.all(promises);
55
- }
56
- }
57
- //TODO: move this function within protocol SDK class: https://github.com/waku-org/js-waku/issues/1761
58
- /**
59
- * Wait for a peer with the given protocol to be connected.
60
- * If sharding is enabled on the node, it will also wait for the peer to be confirmed by the metadata service.
61
- */
62
- async function waitForConnectedPeer(protocol, metadataService) {
63
- const codec = protocol.multicodec;
64
- const peers = await protocol.connectedPeers();
65
- if (peers.length) {
66
- if (!metadataService) {
67
- log.info(`${codec} peer found: `, peers[0].id.toString());
68
- return;
69
- }
70
- // once a peer is connected, we need to confirm the metadata handshake with at least one of those peers if sharding is enabled
71
- try {
72
- await Promise.any(peers.map((peer) => metadataService.confirmOrAttemptHandshake(peer.id)));
73
- return;
74
- }
75
- catch (e) {
76
- if (e.code === "ERR_CONNECTION_BEING_CLOSED")
77
- log.error(`Connection with the peer was closed and possibly because it's on a different shard. Error: ${e}`);
78
- log.error(`Error waiting for handshake confirmation: ${e}`);
79
- }
80
- }
81
- log.info(`Waiting for ${codec} peer`);
82
- // else we'll just wait for the next peer to connect
83
- await new Promise((resolve) => {
84
- const cb = (evt) => {
85
- if (evt.detail?.protocols?.includes(codec)) {
86
- if (metadataService) {
87
- metadataService
88
- .confirmOrAttemptHandshake(evt.detail.peerId)
89
- .then(() => {
90
- protocol.removeLibp2pEventListener("peer:identify", cb);
91
- resolve();
92
- })
93
- .catch((e) => {
94
- if (e.code === "ERR_CONNECTION_BEING_CLOSED")
95
- log.error(`Connection with the peer was closed and possibly because it's on a different shard. Error: ${e}`);
96
- log.error(`Error waiting for handshake confirmation: ${e}`);
97
- });
98
- }
99
- else {
100
- protocol.removeLibp2pEventListener("peer:identify", cb);
101
- resolve();
102
- }
103
- }
104
- };
105
- protocol.addLibp2pEventListener("peer:identify", cb);
106
- });
107
- }
108
- /**
109
- * Wait for at least one peer with the given protocol to be connected and in the gossipsub
110
- * mesh for all pubsubTopics.
111
- */
112
- async function waitForGossipSubPeerInMesh(waku) {
113
- let peers = waku.getMeshPeers();
114
- const pubsubTopics = waku.pubsubTopics;
115
- for (const topic of pubsubTopics) {
116
- while (peers.length == 0) {
117
- await pEvent(waku.gossipSub, "gossipsub:heartbeat");
118
- peers = waku.getMeshPeers(topic);
119
- }
120
- }
121
- }
122
- const awaitTimeout = (ms, rejectReason) => new Promise((_resolve, reject) => setTimeout(() => reject(rejectReason), ms));
123
- async function rejectOnTimeout(promise, timeoutMs, rejectReason) {
124
- await Promise.race([promise, awaitTimeout(timeoutMs, rejectReason)]);
125
- }
126
- function getEnabledProtocols(waku) {
127
- const protocols = [];
128
- if (waku.relay) {
129
- protocols.push(Protocols.Relay);
130
- }
131
- if (waku.filter) {
132
- protocols.push(Protocols.Filter);
133
- }
134
- if (waku.store) {
135
- protocols.push(Protocols.Store);
136
- }
137
- if (waku.lightPush) {
138
- protocols.push(Protocols.LightPush);
139
- }
140
- return protocols;
141
- }
142
- //# sourceMappingURL=wait_for_remote_peer.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"wait_for_remote_peer.js","sourceRoot":"","sources":["../../src/lib/wait_for_remote_peer.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,MAAM,GAAG,GAAG,IAAI,MAAM,CAAC,sBAAsB,CAAC,CAAC;AAE/C,iGAAiG;AACjG;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,IAAU,EACV,SAAuB,EACvB,SAAkB;IAElB,SAAS,GAAG,SAAS,IAAI,mBAAmB,CAAC,IAAI,CAAC,CAAC;IAEnD,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE;QAAE,OAAO,OAAO,CAAC,MAAM,CAAC,0BAA0B,CAAC,CAAC;IAEzE,MAAM,QAAQ,GAAG,EAAE,CAAC;IAEpB,IAAI,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC;QACxC,IAAI,CAAC,IAAI,CAAC,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