@waku/core 0.0.34-1c0c5ee.0 → 0.0.34-3670e82.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.
Files changed (84) hide show
  1. package/bundle/base_protocol-Bp5a9PNG.js +152 -0
  2. package/bundle/{index-BIW3qNYx.js → index-G1eRBjeI.js} +118 -204
  3. package/bundle/index.js +1895 -178
  4. package/bundle/lib/base_protocol.js +2 -2
  5. package/bundle/lib/message/version_0.js +2 -2
  6. package/bundle/{version_0-CdmZMfkQ.js → version_0-DJZG2fB2.js} +283 -45
  7. package/dist/.tsbuildinfo +1 -1
  8. package/dist/index.d.ts +1 -3
  9. package/dist/index.js +1 -3
  10. package/dist/index.js.map +1 -1
  11. package/dist/lib/base_protocol.d.ts +3 -23
  12. package/dist/lib/base_protocol.js +3 -47
  13. package/dist/lib/base_protocol.js.map +1 -1
  14. package/dist/lib/connection_manager/connection_manager.d.ts +118 -0
  15. package/dist/lib/{connection_manager.js → connection_manager/connection_manager.js} +136 -36
  16. package/dist/lib/connection_manager/connection_manager.js.map +1 -0
  17. package/dist/lib/connection_manager/index.d.ts +1 -0
  18. package/dist/lib/connection_manager/index.js +2 -0
  19. package/dist/lib/connection_manager/index.js.map +1 -0
  20. package/dist/lib/{keep_alive_manager.d.ts → connection_manager/keep_alive_manager.d.ts} +4 -2
  21. package/dist/lib/{keep_alive_manager.js → connection_manager/keep_alive_manager.js} +2 -2
  22. package/dist/lib/connection_manager/keep_alive_manager.js.map +1 -0
  23. package/dist/lib/connection_manager/utils.d.ts +7 -0
  24. package/dist/lib/connection_manager/utils.js +22 -0
  25. package/dist/lib/connection_manager/utils.js.map +1 -0
  26. package/dist/lib/filter/filter.d.ts +18 -0
  27. package/dist/lib/filter/filter.js +209 -0
  28. package/dist/lib/filter/filter.js.map +1 -0
  29. package/dist/lib/filter/index.d.ts +1 -18
  30. package/dist/lib/filter/index.js +1 -208
  31. package/dist/lib/filter/index.js.map +1 -1
  32. package/dist/lib/light_push/index.d.ts +1 -15
  33. package/dist/lib/light_push/index.js +1 -143
  34. package/dist/lib/light_push/index.js.map +1 -1
  35. package/dist/lib/light_push/light_push.d.ts +15 -0
  36. package/dist/lib/light_push/light_push.js +144 -0
  37. package/dist/lib/light_push/light_push.js.map +1 -0
  38. package/dist/lib/light_push/utils.d.ts +0 -2
  39. package/dist/lib/light_push/utils.js +9 -17
  40. package/dist/lib/light_push/utils.js.map +1 -1
  41. package/dist/lib/metadata/index.d.ts +1 -3
  42. package/dist/lib/metadata/index.js +1 -118
  43. package/dist/lib/metadata/index.js.map +1 -1
  44. package/dist/lib/metadata/metadata.d.ts +3 -0
  45. package/dist/lib/metadata/metadata.js +119 -0
  46. package/dist/lib/metadata/metadata.js.map +1 -0
  47. package/dist/lib/store/index.d.ts +1 -9
  48. package/dist/lib/store/index.js +1 -82
  49. package/dist/lib/store/index.js.map +1 -1
  50. package/dist/lib/store/store.d.ts +9 -0
  51. package/dist/lib/store/store.js +83 -0
  52. package/dist/lib/store/store.js.map +1 -0
  53. package/dist/lib/stream_manager/stream_manager.d.ts +2 -2
  54. package/dist/lib/stream_manager/stream_manager.js +16 -17
  55. package/dist/lib/stream_manager/stream_manager.js.map +1 -1
  56. package/package.json +1 -1
  57. package/src/index.ts +1 -4
  58. package/src/lib/base_protocol.ts +3 -76
  59. package/src/lib/{connection_manager.ts → connection_manager/connection_manager.ts} +168 -63
  60. package/src/lib/connection_manager/index.ts +1 -0
  61. package/src/lib/{keep_alive_manager.ts → connection_manager/keep_alive_manager.ts} +7 -3
  62. package/src/lib/connection_manager/utils.ts +25 -0
  63. package/src/lib/filter/filter.ts +315 -0
  64. package/src/lib/filter/index.ts +1 -315
  65. package/src/lib/light_push/index.ts +1 -188
  66. package/src/lib/light_push/light_push.ts +188 -0
  67. package/src/lib/light_push/utils.ts +13 -21
  68. package/src/lib/metadata/index.ts +1 -182
  69. package/src/lib/metadata/metadata.ts +182 -0
  70. package/src/lib/store/index.ts +1 -136
  71. package/src/lib/store/store.ts +136 -0
  72. package/src/lib/stream_manager/stream_manager.ts +16 -18
  73. package/bundle/base_protocol-Dzv-QHPR.js +0 -275
  74. package/dist/lib/connection_manager.d.ts +0 -62
  75. package/dist/lib/connection_manager.js.map +0 -1
  76. package/dist/lib/filterPeers.d.ts +0 -13
  77. package/dist/lib/filterPeers.js +0 -38
  78. package/dist/lib/filterPeers.js.map +0 -1
  79. package/dist/lib/health_manager.d.ts +0 -14
  80. package/dist/lib/health_manager.js +0 -70
  81. package/dist/lib/health_manager.js.map +0 -1
  82. package/dist/lib/keep_alive_manager.js.map +0 -1
  83. package/src/lib/filterPeers.ts +0 -51
  84. package/src/lib/health_manager.ts +0 -90
@@ -0,0 +1,118 @@
1
+ import { type Connection, type Peer, type PeerId, type Stream, TypedEventEmitter } from "@libp2p/interface";
2
+ import { MultiaddrInput } from "@multiformats/multiaddr";
3
+ import { ConnectionManagerOptions, IConnectionManager, IConnectionStateEvents, IPeersByDiscoveryEvents, IRelay, PeersByDiscoveryResult, PubsubTopic } from "@waku/interfaces";
4
+ import { Libp2p } from "@waku/interfaces";
5
+ type ConnectionManagerConstructorOptions = {
6
+ libp2p: Libp2p;
7
+ pubsubTopics: PubsubTopic[];
8
+ relay?: IRelay;
9
+ config?: Partial<ConnectionManagerOptions>;
10
+ };
11
+ export declare class ConnectionManager extends TypedEventEmitter<IPeersByDiscoveryEvents & IConnectionStateEvents> implements IConnectionManager {
12
+ readonly pubsubTopics: PubsubTopic[];
13
+ private keepAliveManager;
14
+ private options;
15
+ private libp2p;
16
+ private dialAttemptsForPeer;
17
+ private dialErrorsForPeer;
18
+ private currentActiveParallelDialCount;
19
+ private pendingPeerDialQueue;
20
+ private isP2PNetworkConnected;
21
+ isConnected(): boolean;
22
+ stop(): void;
23
+ dropConnection(peerId: PeerId): Promise<void>;
24
+ getPeersByDiscovery(): Promise<PeersByDiscoveryResult>;
25
+ constructor(options: ConnectionManagerConstructorOptions);
26
+ getConnectedPeers(codec?: string): Promise<Peer[]>;
27
+ private dialPeerStorePeers;
28
+ private startEventListeners;
29
+ /**
30
+ * Attempts to establish a connection with a peer and set up specified protocols.
31
+ * The method handles both PeerId and Multiaddr inputs, manages connection attempts,
32
+ * and maintains the connection state.
33
+ *
34
+ * The dialing process includes:
35
+ * 1. Converting input to dialable peer info
36
+ * 2. Managing parallel dial attempts
37
+ * 3. Attempting to establish protocol-specific connections
38
+ * 4. Handling connection failures and retries
39
+ * 5. Updating the peer store and connection state
40
+ *
41
+ * @param {PeerId | MultiaddrInput} peer - The peer to connect to, either as a PeerId or multiaddr
42
+ * @param {string[]} [protocolCodecs] - Optional array of protocol-specific codec strings to establish
43
+ * (e.g., for LightPush, Filter, Store protocols)
44
+ *
45
+ * @throws {Error} If the multiaddr is missing a peer ID
46
+ * @throws {Error} If the maximum dial attempts are reached and the peer cannot be dialed
47
+ * @throws {Error} If there's an error deleting an undialable peer from the peer store
48
+ *
49
+ * @example
50
+ * ```typescript
51
+ * // Dial using PeerId
52
+ * await connectionManager.dialPeer(peerId);
53
+ *
54
+ * // Dial using multiaddr with specific protocols
55
+ * await connectionManager.dialPeer(multiaddr, [
56
+ * "/vac/waku/relay/2.0.0",
57
+ * "/vac/waku/lightpush/2.0.0-beta1"
58
+ * ]);
59
+ * ```
60
+ *
61
+ * @remarks
62
+ * - The method implements exponential backoff through multiple dial attempts
63
+ * - Maintains a queue for parallel dial attempts (limited by maxParallelDials)
64
+ * - Integrates with the KeepAliveManager for connection maintenance
65
+ * - Updates the peer store and connection state after successful/failed attempts
66
+ * - If all dial attempts fail, triggers DNS discovery as a fallback
67
+ */
68
+ dialPeer(peer: PeerId | MultiaddrInput): Promise<Connection>;
69
+ /**
70
+ * Dial a peer with specific protocols.
71
+ * This method is a raw proxy to the libp2p dialProtocol method.
72
+ * @param peer - The peer to connect to, either as a PeerId or multiaddr
73
+ * @param protocolCodecs - Optional array of protocol-specific codec strings to establish
74
+ * @returns A stream to the peer
75
+ */
76
+ rawDialPeerWithProtocols(peer: PeerId | MultiaddrInput, protocolCodecs: string[]): Promise<Stream>;
77
+ /**
78
+ * Internal utility to extract a PeerId or Multiaddr from a peer input.
79
+ * This is used internally by the connection manager to handle different peer input formats.
80
+ * @internal
81
+ */
82
+ private getDialablePeerInfo;
83
+ private attemptDnsDiscovery;
84
+ private processDialQueue;
85
+ private startPeerDiscoveryListener;
86
+ private startPeerConnectionListener;
87
+ private startPeerDisconnectionListener;
88
+ attemptDial(peerId: PeerId): Promise<void>;
89
+ private onEventHandlers;
90
+ /**
91
+ * Checks if the peer should be dialed based on the following conditions:
92
+ * 1. If the peer is already connected, don't dial
93
+ * 2. If the peer is not part of any of the configured pubsub topics, don't dial
94
+ * 3. If the peer is not dialable based on bootstrap status, don't dial
95
+ * 4. If the peer is already has an active dial attempt, or has been dialed before, don't dial it
96
+ * @returns true if the peer should be dialed, false otherwise
97
+ */
98
+ private shouldDialPeer;
99
+ /**
100
+ * Checks if the peer is dialable based on the following conditions:
101
+ * 1. If the peer is a bootstrap peer, it is only dialable if the number of current bootstrap connections is less than the max allowed.
102
+ * 2. If the peer is not a bootstrap peer
103
+ */
104
+ private isPeerDialableBasedOnBootstrapStatus;
105
+ private dispatchDiscoveryEvent;
106
+ /**
107
+ * Fetches the tag names for a given peer
108
+ */
109
+ private getTagNamesForPeer;
110
+ private isPeerTopicConfigured;
111
+ private getPeerShardInfo;
112
+ private startNetworkStatusListener;
113
+ private stopNetworkStatusListener;
114
+ private setP2PNetworkConnected;
115
+ private setP2PNetworkDisconnected;
116
+ private dispatchWakuConnectionEvent;
117
+ }
118
+ export {};
@@ -1,16 +1,20 @@
1
- import { TypedEventEmitter } from "@libp2p/interface";
1
+ import { isPeerId, TypedEventEmitter } from "@libp2p/interface";
2
+ import { multiaddr } from "@multiformats/multiaddr";
2
3
  import { DNS_DISCOVERY_TAG, EConnectionStateEvents, EPeersByDiscoveryEvents } from "@waku/interfaces";
3
4
  import { Tags } from "@waku/interfaces";
4
5
  import { decodeRelayShard, shardInfoToPubsubTopics } from "@waku/utils";
5
6
  import { Logger } from "@waku/utils";
6
7
  import { KeepAliveManager } from "./keep_alive_manager.js";
8
+ import { getPeerPing } from "./utils.js";
7
9
  const log = new Logger("connection-manager");
8
- export const DEFAULT_MAX_BOOTSTRAP_PEERS_ALLOWED = 1;
9
- export const DEFAULT_MAX_DIAL_ATTEMPTS_FOR_PEER = 3;
10
- export const DEFAULT_MAX_PARALLEL_DIALS = 3;
10
+ const DEFAULT_MAX_BOOTSTRAP_PEERS_ALLOWED = 1;
11
+ const DEFAULT_MAX_DIAL_ATTEMPTS_FOR_PEER = 3;
12
+ const DEFAULT_MAX_PARALLEL_DIALS = 3;
13
+ const DEFAULT_PING_KEEP_ALIVE_SEC = 5 * 60;
14
+ const DEFAULT_RELAY_KEEP_ALIVE_SEC = 5 * 60;
11
15
  export class ConnectionManager extends TypedEventEmitter {
12
- configuredPubsubTopics;
13
- static instances = new Map();
16
+ // TODO(weboko): make it private
17
+ pubsubTopics;
14
18
  keepAliveManager;
15
19
  options;
16
20
  libp2p;
@@ -25,14 +29,6 @@ export class ConnectionManager extends TypedEventEmitter {
25
29
  }
26
30
  return this.isP2PNetworkConnected;
27
31
  }
28
- static create(peerId, libp2p, keepAliveOptions, pubsubTopics, relay, options) {
29
- let instance = ConnectionManager.instances.get(peerId);
30
- if (!instance) {
31
- instance = new ConnectionManager(libp2p, keepAliveOptions, pubsubTopics, relay, options);
32
- ConnectionManager.instances.set(peerId, instance);
33
- }
34
- return instance;
35
- }
36
32
  stop() {
37
33
  this.keepAliveManager.stopAll();
38
34
  this.libp2p.removeEventListener("peer:connect", this.onEventHandlers["peer:connect"]);
@@ -99,21 +95,25 @@ export class ConnectionManager extends TypedEventEmitter {
99
95
  }
100
96
  };
101
97
  }
102
- constructor(libp2p, keepAliveOptions, configuredPubsubTopics, relay, options) {
98
+ constructor(options) {
103
99
  super();
104
- this.configuredPubsubTopics = configuredPubsubTopics;
105
- this.libp2p = libp2p;
106
- this.configuredPubsubTopics = configuredPubsubTopics;
100
+ this.libp2p = options.libp2p;
101
+ this.pubsubTopics = options.pubsubTopics;
107
102
  this.options = {
108
103
  maxDialAttemptsForPeer: DEFAULT_MAX_DIAL_ATTEMPTS_FOR_PEER,
109
104
  maxBootstrapPeersAllowed: DEFAULT_MAX_BOOTSTRAP_PEERS_ALLOWED,
110
105
  maxParallelDials: DEFAULT_MAX_PARALLEL_DIALS,
111
- ...options
106
+ pingKeepAlive: DEFAULT_PING_KEEP_ALIVE_SEC,
107
+ relayKeepAlive: DEFAULT_RELAY_KEEP_ALIVE_SEC,
108
+ ...options.config
112
109
  };
113
110
  this.keepAliveManager = new KeepAliveManager({
114
- relay,
115
- libp2p,
116
- options: keepAliveOptions
111
+ relay: options.relay,
112
+ libp2p: options.libp2p,
113
+ options: {
114
+ pingKeepAlive: this.options.pingKeepAlive,
115
+ relayKeepAlive: this.options.relayKeepAlive
116
+ }
117
117
  });
118
118
  this.startEventListeners()
119
119
  .then(() => log.info(`Connection Manager is now running`))
@@ -123,6 +123,24 @@ export class ConnectionManager extends TypedEventEmitter {
123
123
  // we will dial the peers in peerStore ONCE before we start to listen to the `peer:discovery` events within the ConnectionManager
124
124
  this.dialPeerStorePeers().catch((error) => log.error(`Unexpected error while dialing peer store peers`, error));
125
125
  }
126
+ async getConnectedPeers(codec) {
127
+ const peerIDs = this.libp2p.getPeers();
128
+ if (peerIDs.length === 0) {
129
+ return [];
130
+ }
131
+ const peers = await Promise.all(peerIDs.map(async (id) => {
132
+ try {
133
+ return await this.libp2p.peerStore.get(id);
134
+ }
135
+ catch (e) {
136
+ return null;
137
+ }
138
+ }));
139
+ return peers
140
+ .filter((p) => !!p)
141
+ .filter((p) => (codec ? p.protocols.includes(codec) : true))
142
+ .sort((left, right) => getPeerPing(left) - getPeerPing(right));
143
+ }
126
144
  async dialPeerStorePeers() {
127
145
  const peerInfos = await this.libp2p.peerStore.all();
128
146
  const dialPromises = [];
@@ -144,13 +162,59 @@ export class ConnectionManager extends TypedEventEmitter {
144
162
  this.startPeerDisconnectionListener();
145
163
  this.startNetworkStatusListener();
146
164
  }
147
- async dialPeer(peerId) {
165
+ /**
166
+ * Attempts to establish a connection with a peer and set up specified protocols.
167
+ * The method handles both PeerId and Multiaddr inputs, manages connection attempts,
168
+ * and maintains the connection state.
169
+ *
170
+ * The dialing process includes:
171
+ * 1. Converting input to dialable peer info
172
+ * 2. Managing parallel dial attempts
173
+ * 3. Attempting to establish protocol-specific connections
174
+ * 4. Handling connection failures and retries
175
+ * 5. Updating the peer store and connection state
176
+ *
177
+ * @param {PeerId | MultiaddrInput} peer - The peer to connect to, either as a PeerId or multiaddr
178
+ * @param {string[]} [protocolCodecs] - Optional array of protocol-specific codec strings to establish
179
+ * (e.g., for LightPush, Filter, Store protocols)
180
+ *
181
+ * @throws {Error} If the multiaddr is missing a peer ID
182
+ * @throws {Error} If the maximum dial attempts are reached and the peer cannot be dialed
183
+ * @throws {Error} If there's an error deleting an undialable peer from the peer store
184
+ *
185
+ * @example
186
+ * ```typescript
187
+ * // Dial using PeerId
188
+ * await connectionManager.dialPeer(peerId);
189
+ *
190
+ * // Dial using multiaddr with specific protocols
191
+ * await connectionManager.dialPeer(multiaddr, [
192
+ * "/vac/waku/relay/2.0.0",
193
+ * "/vac/waku/lightpush/2.0.0-beta1"
194
+ * ]);
195
+ * ```
196
+ *
197
+ * @remarks
198
+ * - The method implements exponential backoff through multiple dial attempts
199
+ * - Maintains a queue for parallel dial attempts (limited by maxParallelDials)
200
+ * - Integrates with the KeepAliveManager for connection maintenance
201
+ * - Updates the peer store and connection state after successful/failed attempts
202
+ * - If all dial attempts fail, triggers DNS discovery as a fallback
203
+ */
204
+ async dialPeer(peer) {
205
+ let connection;
206
+ let peerId;
207
+ const peerDialInfo = this.getDialablePeerInfo(peer);
208
+ const peerIdStr = isPeerId(peerDialInfo)
209
+ ? peerDialInfo.toString()
210
+ : peerDialInfo.getPeerId();
148
211
  this.currentActiveParallelDialCount += 1;
149
212
  let dialAttempt = 0;
150
213
  while (dialAttempt < this.options.maxDialAttemptsForPeer) {
151
214
  try {
152
- log.info(`Dialing peer ${peerId.toString()} on attempt ${dialAttempt + 1}`);
153
- await this.libp2p.dial(peerId);
215
+ log.info(`Dialing peer ${peerDialInfo} on attempt ${dialAttempt + 1}`);
216
+ connection = await this.libp2p.dial(peerDialInfo);
217
+ peerId = connection.remotePeer;
154
218
  const tags = await this.getTagNamesForPeer(peerId);
155
219
  // add tag to connection describing discovery mechanism
156
220
  // don't add duplicate tags
@@ -167,15 +231,15 @@ export class ConnectionManager extends TypedEventEmitter {
167
231
  catch (error) {
168
232
  if (error instanceof AggregateError) {
169
233
  // Handle AggregateError
170
- log.error(`Error dialing peer ${peerId.toString()} - ${error.errors}`);
234
+ log.error(`Error dialing peer ${peerIdStr} - ${error.errors}`);
171
235
  }
172
236
  else {
173
237
  // Handle generic error
174
- log.error(`Error dialing peer ${peerId.toString()} - ${error.message}`);
238
+ log.error(`Error dialing peer ${peerIdStr} - ${error.message}`);
175
239
  }
176
- this.dialErrorsForPeer.set(peerId.toString(), error);
240
+ this.dialErrorsForPeer.set(peerIdStr, error);
177
241
  dialAttempt++;
178
- this.dialAttemptsForPeer.set(peerId.toString(), dialAttempt);
242
+ this.dialAttemptsForPeer.set(peerIdStr, dialAttempt);
179
243
  }
180
244
  }
181
245
  // Always decrease the active dial count and process the dial queue
@@ -184,7 +248,7 @@ export class ConnectionManager extends TypedEventEmitter {
184
248
  // If max dial attempts reached and dialing failed, delete the peer
185
249
  if (dialAttempt === this.options.maxDialAttemptsForPeer) {
186
250
  try {
187
- const error = this.dialErrorsForPeer.get(peerId.toString());
251
+ const error = this.dialErrorsForPeer.get(peerIdStr);
188
252
  if (error) {
189
253
  let errorMessage;
190
254
  if (error instanceof AggregateError) {
@@ -201,16 +265,52 @@ export class ConnectionManager extends TypedEventEmitter {
201
265
  else {
202
266
  errorMessage = error.message;
203
267
  }
204
- log.info(`Deleting undialable peer ${peerId.toString()} from peer store. Reason: ${errorMessage}`);
268
+ log.info(`Deleting undialable peer ${peerIdStr} from peer store. Reason: ${errorMessage}`);
269
+ }
270
+ this.dialErrorsForPeer.delete(peerIdStr);
271
+ if (peerId) {
272
+ await this.libp2p.peerStore.delete(peerId);
205
273
  }
206
- this.dialErrorsForPeer.delete(peerId.toString());
207
- await this.libp2p.peerStore.delete(peerId);
208
274
  // if it was last available peer - attempt DNS discovery
209
275
  await this.attemptDnsDiscovery();
210
276
  }
211
277
  catch (error) {
212
- throw new Error(`Error deleting undialable peer ${peerId.toString()} from peer store - ${error}`);
278
+ throw new Error(`Error deleting undialable peer ${peerIdStr} from peer store - ${error}`);
279
+ }
280
+ }
281
+ if (!connection) {
282
+ throw new Error(`Failed to dial peer ${peerDialInfo}`);
283
+ }
284
+ return connection;
285
+ }
286
+ /**
287
+ * Dial a peer with specific protocols.
288
+ * This method is a raw proxy to the libp2p dialProtocol method.
289
+ * @param peer - The peer to connect to, either as a PeerId or multiaddr
290
+ * @param protocolCodecs - Optional array of protocol-specific codec strings to establish
291
+ * @returns A stream to the peer
292
+ */
293
+ async rawDialPeerWithProtocols(peer, protocolCodecs) {
294
+ const peerDialInfo = this.getDialablePeerInfo(peer);
295
+ return await this.libp2p.dialProtocol(peerDialInfo, protocolCodecs);
296
+ }
297
+ /**
298
+ * Internal utility to extract a PeerId or Multiaddr from a peer input.
299
+ * This is used internally by the connection manager to handle different peer input formats.
300
+ * @internal
301
+ */
302
+ getDialablePeerInfo(peer) {
303
+ if (isPeerId(peer)) {
304
+ return peer;
305
+ }
306
+ else {
307
+ // peer is of MultiaddrInput type
308
+ const ma = multiaddr(peer);
309
+ const peerIdStr = ma.getPeerId();
310
+ if (!peerIdStr) {
311
+ throw new Error("Failed to dial multiaddr: missing peer ID");
213
312
  }
313
+ return ma;
214
314
  }
215
315
  }
216
316
  async attemptDnsDiscovery() {
@@ -338,7 +438,7 @@ export class ConnectionManager extends TypedEventEmitter {
338
438
  const isSameShard = await this.isPeerTopicConfigured(peerId);
339
439
  if (!isSameShard) {
340
440
  const shardInfo = await this.getPeerShardInfo(peerId, this.libp2p.peerStore);
341
- log.warn(`Discovered peer ${peerId.toString()} with ShardInfo ${shardInfo} is not part of any of the configured pubsub topics (${this.configuredPubsubTopics}).
441
+ log.warn(`Discovered peer ${peerId.toString()} with ShardInfo ${shardInfo} is not part of any of the configured pubsub topics (${this.pubsubTopics}).
342
442
  Not dialing.`);
343
443
  return false;
344
444
  }
@@ -399,7 +499,7 @@ export class ConnectionManager extends TypedEventEmitter {
399
499
  if (!shardInfo)
400
500
  return true;
401
501
  const pubsubTopics = shardInfoToPubsubTopics(shardInfo);
402
- const isTopicConfigured = pubsubTopics.some((topic) => this.configuredPubsubTopics.includes(topic));
502
+ const isTopicConfigured = pubsubTopics.some((topic) => this.pubsubTopics.includes(topic));
403
503
  return isTopicConfigured;
404
504
  }
405
505
  async getPeerShardInfo(peerId, peerStore) {
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connection_manager.js","sourceRoot":"","sources":["../../../src/lib/connection_manager/connection_manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,EAMR,iBAAiB,EAClB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAa,SAAS,EAAkB,MAAM,yBAAyB,CAAC;AAC/E,OAAO,EAGL,iBAAiB,EACjB,sBAAsB,EACtB,uBAAuB,EAQxB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAU,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AACxE,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEzC,MAAM,GAAG,GAAG,IAAI,MAAM,CAAC,oBAAoB,CAAC,CAAC;AAE7C,MAAM,mCAAmC,GAAG,C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CAAC,qBAAqB,EAAE,CAAC;YAChC,IAAI,CAAC,qBAAqB,GAAG,IAAI,CAAC;YAClC,IAAI,CAAC,2BAA2B,EAAE,CAAC;QACrC,CAAC;IACH,CAAC;IAEO,yBAAyB;QAC/B,IACE,IAAI,CAAC,qBAAqB;YAC1B,IAAI,CAAC,MAAM,CAAC,cAAc,EAAE,CAAC,MAAM,KAAK,CAAC,EACzC,CAAC;YACD,IAAI,CAAC,qBAAqB,GAAG,KAAK,CAAC;YACnC,IAAI,CAAC,2BAA2B,EAAE,CAAC;QACrC,CAAC;IACH,CAAC;IAEO,2BAA2B;QACjC,IAAI,CAAC,aAAa,CAChB,IAAI,WAAW,CAAU,sBAAsB,CAAC,iBAAiB,EAAE;YACjE,MAAM,EAAE,IAAI,CAAC,WAAW,EAAE;SAC3B,CAAC,CACH,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1 @@
1
+ export { ConnectionManager } from "./connection_manager.js";
@@ -0,0 +1,2 @@
1
+ export { ConnectionManager } from "./connection_manager.js";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/connection_manager/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC"}
@@ -1,7 +1,9 @@
1
1
  import type { PeerId } from "@libp2p/interface";
2
2
  import type { IRelay, Libp2p } from "@waku/interfaces";
3
- import type { KeepAliveOptions } from "@waku/interfaces";
4
- export declare const RelayPingContentTopic = "/relay-ping/1/ping/null";
3
+ type KeepAliveOptions = {
4
+ pingKeepAlive: number;
5
+ relayKeepAlive: number;
6
+ };
5
7
  type CreateKeepAliveManagerOptions = {
6
8
  options: KeepAliveOptions;
7
9
  libp2p: Libp2p;
@@ -1,7 +1,7 @@
1
1
  import { Logger, pubsubTopicToSingleShardInfo } from "@waku/utils";
2
2
  import { utf8ToBytes } from "@waku/utils/bytes";
3
- import { createEncoder } from "./message/version_0.js";
4
- export const RelayPingContentTopic = "/relay-ping/1/ping/null";
3
+ import { createEncoder } from "../message/version_0.js";
4
+ const RelayPingContentTopic = "/relay-ping/1/ping/null";
5
5
  const log = new Logger("keep-alive");
6
6
  export class KeepAliveManager {
7
7
  relay;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keep_alive_manager.js","sourceRoot":"","sources":["../../../src/lib/connection_manager/keep_alive_manager.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAExD,MAAM,qBAAqB,GAAG,yBAAyB,CAAC;AACxD,MAAM,GAAG,GAAG,IAAI,MAAM,CAAC,YAAY,CAAC,CAAC;AAarC,MAAM,OAAO,gBAAgB;IACV,KAAK,CAAU;IACf,MAAM,CAAS;IAEf,OAAO,CAAmB;IAEnC,mBAAmB,GACzB,IAAI,GAAG,EAAE,CAAC;IACJ,oBAAoB,GAC1B,IAAI,GAAG,EAAE,CAAC;IAEZ,YAAmB,EACjB,OAAO,EACP,KAAK,EACL,MAAM,EACwB;QAC9B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAEM,KAAK,CAAC,MAAc;QACzB,oDAAoD;QACpD,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAElB,MAAM,EAAE,aAAa,EAAE,cAAc,EAAE,cAAc,EAAE,eAAe,EAAE,GACtE,IAAI,CAAC,OAAO,CAAC;QAEf,MAAM,SAAS,GAAG,MAAM,CAAC,QAAQ,EAAE,CAAC;QAEpC,6CAA6C;QAC7C,8CAA8C;QAC9C,IAAI,cAAc,KAAK,CAAC,EAAE,CAAC;YACzB,MAAM,Q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;IACJ,CAAC;IAEO,kBAAkB,CACxB,KAAa,EACb,eAAuB,EACvB,SAAoB;QAEpB,8DAA8D;QAC9D,MAAM,SAAS,GAAqB,EAAE,CAAC;QACvC,KAAK,MAAM,KAAK,IAAI,KAAK,CAAC,YAAY,EAAE,CAAC;YACvC,MAAM,SAAS,GAAG,KAAK,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;YAC5C,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC;gBAAE,SAAS;YAE7C,MAAM,OAAO,GAAG,aAAa,CAAC;gBAC5B,oBAAoB,EAAE,4BAA4B,CAAC,KAAK,CAAC;gBACzD,YAAY,EAAE,qBAAqB;gBACnC,SAAS,EAAE,IAAI;aAChB,CAAC,CAAC;YACH,MAAM,QAAQ,GAAG,WAAW,CAAC,GAAG,EAAE;gBAChC,GAAG,CAAC,IAAI,CAAC,iCAAiC,CAAC,CAAC;gBAC5C,KAAK;qBACF,IAAI,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,IAAI,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;qBAC/C,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,2BAA2B,EAAE,CAAC,CAAC,CAAC,CAAC;YAC7D,CAAC,EAAE,eAAe,GAAG,IAAI,CAAC,CAAC;YAC3B,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC3B,CAAC;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;CACF"}
@@ -0,0 +1,7 @@
1
+ import type { Peer } from "@libp2p/interface";
2
+ /**
3
+ * Reads peer's metadata and retrieves ping value.
4
+ * @param peer Peer or null
5
+ * @returns -1 if no ping attached, otherwise returns ping value
6
+ */
7
+ export declare const getPeerPing: (peer: Peer | null) => number;
@@ -0,0 +1,22 @@
1
+ import { bytesToUtf8 } from "@waku/utils/bytes";
2
+ /**
3
+ * Reads peer's metadata and retrieves ping value.
4
+ * @param peer Peer or null
5
+ * @returns -1 if no ping attached, otherwise returns ping value
6
+ */
7
+ export const getPeerPing = (peer) => {
8
+ if (!peer) {
9
+ return -1;
10
+ }
11
+ try {
12
+ const bytes = peer.metadata.get("ping");
13
+ if (!bytes) {
14
+ return -1;
15
+ }
16
+ return Number(bytesToUtf8(bytes));
17
+ }
18
+ catch (e) {
19
+ return -1;
20
+ }
21
+ };
22
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/lib/connection_manager/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD;;;;GAIG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,IAAiB,EAAU,EAAE;IACvD,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,OAAO,CAAC,CAAC,CAAC;IACZ,CAAC;IAED,IAAI,CAAC;QACH,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QAExC,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,OAAO,CAAC,CAAC,CAAC;QACZ,CAAC;QAED,OAAO,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC;IACpC,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,CAAC,CAAC,CAAC;IACZ,CAAC;AACH,CAAC,CAAC"}
@@ -0,0 +1,18 @@
1
+ import type { PeerId } from "@libp2p/interface";
2
+ import { type ContentTopic, type CoreProtocolResult, type IBaseProtocolCore, type Libp2p, type PubsubTopic } from "@waku/interfaces";
3
+ import { WakuMessage } from "@waku/proto";
4
+ import { BaseProtocol } from "../base_protocol.js";
5
+ export declare const FilterCodecs: {
6
+ SUBSCRIBE: string;
7
+ PUSH: string;
8
+ };
9
+ export declare class FilterCore extends BaseProtocol implements IBaseProtocolCore {
10
+ private handleIncomingMessage;
11
+ readonly pubsubTopics: PubsubTopic[];
12
+ constructor(handleIncomingMessage: (pubsubTopic: PubsubTopic, wakuMessage: WakuMessage, peerIdStr: string) => Promise<void>, pubsubTopics: PubsubTopic[], libp2p: Libp2p);
13
+ subscribe(pubsubTopic: PubsubTopic, peerId: PeerId, contentTopics: ContentTopic[]): Promise<CoreProtocolResult>;
14
+ unsubscribe(pubsubTopic: PubsubTopic, peerId: PeerId, contentTopics: ContentTopic[]): Promise<CoreProtocolResult>;
15
+ unsubscribeAll(pubsubTopic: PubsubTopic, peerId: PeerId): Promise<CoreProtocolResult>;
16
+ ping(peerId: PeerId): Promise<CoreProtocolResult>;
17
+ private onRequest;
18
+ }