@waku/core 0.0.39-9684e7b.0 → 0.0.39-c0ee9ec.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 (49) hide show
  1. package/bundle/index.js +497 -256
  2. package/bundle/lib/message/version_0.js +1 -1
  3. package/bundle/{version_0-DV1Db0r-.js → version_0-DQUncDnb.js} +3 -3
  4. package/dist/.tsbuildinfo +1 -1
  5. package/dist/index.d.ts +1 -1
  6. package/dist/index.js +1 -1
  7. package/dist/index.js.map +1 -1
  8. package/dist/lib/connection_manager/connection_limiter.js +3 -3
  9. package/dist/lib/connection_manager/connection_limiter.js.map +1 -1
  10. package/dist/lib/connection_manager/network_monitor.js +1 -2
  11. package/dist/lib/connection_manager/network_monitor.js.map +1 -1
  12. package/dist/lib/filter/filter.d.ts +6 -6
  13. package/dist/lib/filter/filter.js +14 -14
  14. package/dist/lib/filter/filter.js.map +1 -1
  15. package/dist/lib/light_push/index.d.ts +1 -1
  16. package/dist/lib/light_push/index.js +1 -1
  17. package/dist/lib/light_push/index.js.map +1 -1
  18. package/dist/lib/light_push/light_push.d.ts +8 -6
  19. package/dist/lib/light_push/light_push.js +40 -79
  20. package/dist/lib/light_push/light_push.js.map +1 -1
  21. package/dist/lib/light_push/protocol_handler.d.ts +27 -0
  22. package/dist/lib/light_push/protocol_handler.js +145 -0
  23. package/dist/lib/light_push/protocol_handler.js.map +1 -0
  24. package/dist/lib/light_push/push_rpc.d.ts +3 -3
  25. package/dist/lib/light_push/push_rpc.js +3 -3
  26. package/dist/lib/light_push/push_rpc.js.map +1 -1
  27. package/dist/lib/light_push/push_rpc_v3.d.ts +73 -0
  28. package/dist/lib/light_push/push_rpc_v3.js +136 -0
  29. package/dist/lib/light_push/push_rpc_v3.js.map +1 -0
  30. package/dist/lib/metadata/metadata.js +1 -1
  31. package/dist/lib/metadata/metadata.js.map +1 -1
  32. package/dist/lib/store/store.d.ts +1 -1
  33. package/dist/lib/store/store.js +1 -1
  34. package/dist/lib/store/store.js.map +1 -1
  35. package/dist/lib/stream_manager/stream_manager.d.ts +1 -1
  36. package/dist/lib/stream_manager/stream_manager.js.map +1 -1
  37. package/package.json +1 -1
  38. package/src/index.ts +5 -1
  39. package/src/lib/connection_manager/connection_limiter.ts +3 -7
  40. package/src/lib/connection_manager/network_monitor.ts +2 -2
  41. package/src/lib/filter/filter.ts +19 -19
  42. package/src/lib/light_push/index.ts +5 -1
  43. package/src/lib/light_push/light_push.ts +59 -106
  44. package/src/lib/light_push/protocol_handler.ts +192 -0
  45. package/src/lib/light_push/push_rpc.ts +5 -5
  46. package/src/lib/light_push/push_rpc_v3.ts +162 -0
  47. package/src/lib/metadata/metadata.ts +1 -1
  48. package/src/lib/store/store.ts +1 -1
  49. package/src/lib/stream_manager/stream_manager.ts +1 -1
@@ -1,14 +1,12 @@
1
- import type { PeerId } from "@libp2p/interface";
1
+ import type { PeerId, Stream } from "@libp2p/interface";
2
2
  import {
3
- type CoreProtocolResult,
4
3
  type IEncoder,
5
4
  type IMessage,
6
5
  type Libp2p,
7
- ProtocolError,
8
- type ThisOrThat
6
+ type LightPushCoreResult,
7
+ LightPushError
9
8
  } from "@waku/interfaces";
10
9
  import { PushResponse } from "@waku/proto";
11
- import { isMessageSizeUnderCap } from "@waku/utils";
12
10
  import { Logger } from "@waku/utils";
13
11
  import all from "it-all";
14
12
  import * as lp from "it-length-prefixed";
@@ -17,170 +15,125 @@ import { Uint8ArrayList } from "uint8arraylist";
17
15
 
18
16
  import { StreamManager } from "../stream_manager/index.js";
19
17
 
20
- import { PushRpc } from "./push_rpc.js";
21
- import { isRLNResponseError } from "./utils.js";
18
+ import { CODECS, ProtocolHandler } from "./protocol_handler.js";
22
19
 
23
20
  const log = new Logger("light-push");
24
21
 
25
- export const LightPushCodec = "/vac/waku/lightpush/2.0.0-beta1";
26
22
  export { PushResponse };
27
23
 
28
- type PreparePushMessageResult = ThisOrThat<"query", PushRpc>;
24
+ export const LightPushCodec = CODECS.v3;
25
+ export const LightPushCodecV2 = CODECS.v2;
29
26
 
30
27
  /**
31
28
  * Implements the [Waku v2 Light Push protocol](https://rfc.vac.dev/spec/19/).
32
29
  */
33
30
  export class LightPushCore {
34
31
  private readonly streamManager: StreamManager;
35
-
36
- public readonly multicodec = LightPushCodec;
37
-
38
- public constructor(libp2p: Libp2p) {
39
- this.streamManager = new StreamManager(LightPushCodec, libp2p.components);
40
- }
41
-
42
- private async preparePushMessage(
43
- encoder: IEncoder,
44
- message: IMessage
45
- ): Promise<PreparePushMessageResult> {
46
- try {
47
- if (!message.payload || message.payload.length === 0) {
48
- log.error("Failed to send waku light push: payload is empty");
49
- return { query: null, error: ProtocolError.EMPTY_PAYLOAD };
50
- }
51
-
52
- if (!(await isMessageSizeUnderCap(encoder, message))) {
53
- log.error("Failed to send waku light push: message is bigger than 1MB");
54
- return { query: null, error: ProtocolError.SIZE_TOO_BIG };
55
- }
56
-
57
- const protoMessage = await encoder.toProtoObj(message);
58
- if (!protoMessage) {
59
- log.error("Failed to encode to protoMessage, aborting push");
60
- return {
61
- query: null,
62
- error: ProtocolError.ENCODE_FAILED
63
- };
64
- }
65
-
66
- const query = PushRpc.createRequest(protoMessage, encoder.pubsubTopic);
67
- return { query, error: null };
68
- } catch (error) {
69
- log.error("Failed to prepare push message", error);
70
-
71
- return {
72
- query: null,
73
- error: ProtocolError.GENERIC_FAIL
74
- };
75
- }
32
+ private readonly streamManagerV2: StreamManager;
33
+ public readonly multicodec = [CODECS.v3, CODECS.v2];
34
+
35
+ public constructor(
36
+ private libp2p: Libp2p,
37
+ legacy?: boolean
38
+ ) {
39
+ this.streamManagerV2 = new StreamManager(CODECS.v2, libp2p.components);
40
+ this.streamManager = legacy
41
+ ? this.streamManagerV2
42
+ : new StreamManager(CODECS.v3, libp2p.components);
76
43
  }
77
44
 
78
45
  public async send(
79
46
  encoder: IEncoder,
80
47
  message: IMessage,
81
48
  peerId: PeerId
82
- ): Promise<CoreProtocolResult> {
83
- const { query, error: preparationError } = await this.preparePushMessage(
84
- encoder,
85
- message
86
- );
49
+ ): Promise<LightPushCoreResult> {
50
+ let stream: Stream | undefined;
51
+ let protocol: string;
87
52
 
88
- if (preparationError || !query) {
53
+ try {
54
+ const peer = await this.libp2p.peerStore.get(peerId);
55
+
56
+ if (
57
+ this.streamManager.multicodec === CODECS.v3 &&
58
+ peer.protocols.includes(CODECS.v3)
59
+ ) {
60
+ stream = await this.streamManager.getStream(peerId);
61
+ protocol = CODECS.v3;
62
+ } else {
63
+ stream = await this.streamManagerV2.getStream(peerId);
64
+ protocol = CODECS.v2;
65
+ }
66
+ } catch (error) {
67
+ log.error("Failed to get stream", error);
89
68
  return {
90
69
  success: null,
91
70
  failure: {
92
- error: preparationError,
71
+ error: LightPushError.GENERIC_FAIL,
93
72
  peerId
94
73
  }
95
74
  };
96
75
  }
97
76
 
98
- const stream = await this.streamManager.getStream(peerId);
99
-
100
77
  if (!stream) {
101
78
  log.error(`Failed to get a stream for remote peer:${peerId.toString()}`);
102
79
  return {
103
80
  success: null,
104
81
  failure: {
105
- error: ProtocolError.NO_STREAM_AVAILABLE,
82
+ error: LightPushError.NO_STREAM_AVAILABLE,
106
83
  peerId: peerId
107
84
  }
108
85
  };
109
86
  }
110
87
 
88
+ const { rpc, error: prepError } = await ProtocolHandler.preparePushMessage(
89
+ encoder,
90
+ message,
91
+ protocol
92
+ );
93
+
94
+ if (prepError || !rpc) {
95
+ return {
96
+ success: null,
97
+ failure: {
98
+ error: prepError ?? LightPushError.GENERIC_FAIL,
99
+ peerId
100
+ }
101
+ };
102
+ }
103
+
111
104
  let res: Uint8ArrayList[] | undefined;
112
105
  try {
113
106
  res = await pipe(
114
- [query.encode()],
107
+ [rpc.encode()],
115
108
  lp.encode,
116
109
  stream,
117
110
  lp.decode,
118
111
  async (source) => await all(source)
119
112
  );
120
113
  } catch (err) {
121
- // can fail only because of `stream` abortion
122
114
  log.error("Failed to send waku light push request", err);
123
115
  return {
124
116
  success: null,
125
117
  failure: {
126
- error: ProtocolError.STREAM_ABORTED,
118
+ error: LightPushError.STREAM_ABORTED,
127
119
  peerId: peerId
128
120
  }
129
121
  };
130
122
  }
131
123
 
132
124
  const bytes = new Uint8ArrayList();
133
- res.forEach((chunk) => {
134
- bytes.append(chunk);
135
- });
136
-
137
- let response: PushResponse | undefined;
138
- try {
139
- response = PushRpc.decode(bytes).response;
140
- } catch (err) {
141
- log.error("Failed to decode push reply", err);
142
- return {
143
- success: null,
144
- failure: {
145
- error: ProtocolError.DECODE_FAILED,
146
- peerId: peerId
147
- }
148
- };
149
- }
150
-
151
- if (!response) {
152
- log.error("Remote peer fault: No response in PushRPC");
153
- return {
154
- success: null,
155
- failure: {
156
- error: ProtocolError.NO_RESPONSE,
157
- peerId: peerId
158
- }
159
- };
160
- }
161
-
162
- if (isRLNResponseError(response.info)) {
163
- log.error("Remote peer fault: RLN generation");
164
- return {
165
- success: null,
166
- failure: {
167
- error: ProtocolError.RLN_PROOF_GENERATION,
168
- peerId: peerId
169
- }
170
- };
171
- }
125
+ res.forEach((chunk) => bytes.append(chunk));
172
126
 
173
- if (!response.isSuccess) {
174
- log.error("Remote peer rejected the message: ", response.info);
127
+ if (bytes.length === 0) {
175
128
  return {
176
129
  success: null,
177
130
  failure: {
178
- error: ProtocolError.REMOTE_PEER_REJECTED,
131
+ error: LightPushError.NO_RESPONSE,
179
132
  peerId: peerId
180
133
  }
181
134
  };
182
135
  }
183
136
 
184
- return { success: peerId, failure: null };
137
+ return ProtocolHandler.handleResponse(bytes, protocol, peerId);
185
138
  }
186
139
  }
@@ -0,0 +1,192 @@
1
+ import type { PeerId } from "@libp2p/interface";
2
+ import type { IEncoder, IMessage, LightPushCoreResult } from "@waku/interfaces";
3
+ import { LightPushError, LightPushStatusCode } from "@waku/interfaces";
4
+ import { WakuMessage } from "@waku/proto";
5
+ import { isMessageSizeUnderCap, Logger } from "@waku/utils";
6
+ import { Uint8ArrayList } from "uint8arraylist";
7
+
8
+ import { PushRpcV2 } from "./push_rpc.js";
9
+ import { PushRpc } from "./push_rpc_v3.js";
10
+ import { isRLNResponseError } from "./utils.js";
11
+
12
+ export type VersionedPushRpc =
13
+ | ({ version: "v2" } & PushRpcV2)
14
+ | ({ version: "v3" } & PushRpc);
15
+
16
+ export const CODECS = {
17
+ v2: "/vac/waku/lightpush/2.0.0-beta1",
18
+ v3: "/vac/waku/lightpush/3.0.0"
19
+ } as const;
20
+
21
+ const log = new Logger("light-push:protocol-handler");
22
+
23
+ export class ProtocolHandler {
24
+ public static async preparePushMessage(
25
+ encoder: IEncoder,
26
+ message: IMessage,
27
+ protocol: string
28
+ ): Promise<{ rpc: VersionedPushRpc | null; error: LightPushError | null }> {
29
+ try {
30
+ if (!message.payload || message.payload.length === 0) {
31
+ log.error("Failed to send waku light push: payload is empty");
32
+ return { rpc: null, error: LightPushError.EMPTY_PAYLOAD };
33
+ }
34
+
35
+ if (!(await isMessageSizeUnderCap(encoder, message))) {
36
+ log.error("Failed to send waku light push: message is bigger than 1MB");
37
+ return { rpc: null, error: LightPushError.SIZE_TOO_BIG };
38
+ }
39
+
40
+ const protoMessage = await encoder.toProtoObj(message);
41
+ if (!protoMessage) {
42
+ log.error("Failed to encode to protoMessage, aborting push");
43
+ return { rpc: null, error: LightPushError.ENCODE_FAILED };
44
+ }
45
+
46
+ // Select version implementation
47
+ if (protocol === CODECS.v3) {
48
+ log.info("Creating v3 RPC message");
49
+ return {
50
+ rpc: createV3Rpc(protoMessage, encoder.pubsubTopic),
51
+ error: null
52
+ };
53
+ }
54
+
55
+ // Default to v2
56
+ log.info("Creating v2 RPC message");
57
+ return {
58
+ rpc: createV2Rpc(protoMessage, encoder.pubsubTopic),
59
+ error: null
60
+ };
61
+ } catch (err) {
62
+ log.error("Failed to prepare push message", err);
63
+ return { rpc: null, error: LightPushError.GENERIC_FAIL };
64
+ }
65
+ }
66
+
67
+ /**
68
+ * Decode and evaluate a LightPush response according to the protocol version
69
+ */
70
+ public static handleResponse(
71
+ bytes: Uint8ArrayList,
72
+ protocol: string,
73
+ peerId: PeerId
74
+ ): LightPushCoreResult {
75
+ if (protocol === CODECS.v3) {
76
+ return ProtocolHandler.handleV3Response(bytes, peerId);
77
+ }
78
+ return ProtocolHandler.handleV2Response(bytes, peerId);
79
+ }
80
+
81
+ private static handleV3Response(
82
+ bytes: Uint8ArrayList,
83
+ peerId: PeerId
84
+ ): LightPushCoreResult {
85
+ try {
86
+ const decodedRpcV3 = PushRpc.decodeResponse(bytes);
87
+ const statusCode = decodedRpcV3.statusCode;
88
+ const statusDesc = decodedRpcV3.statusDesc;
89
+
90
+ if (statusCode !== LightPushStatusCode.SUCCESS) {
91
+ const error = LightPushError.REMOTE_PEER_REJECTED;
92
+ log.error(
93
+ `Remote peer rejected with v3 status code ${statusCode}: ${statusDesc}`
94
+ );
95
+ return {
96
+ success: null,
97
+ failure: {
98
+ error,
99
+ peerId: peerId
100
+ }
101
+ };
102
+ }
103
+
104
+ if (decodedRpcV3.relayPeerCount !== undefined) {
105
+ log.info(`Message relayed to ${decodedRpcV3.relayPeerCount} peers`);
106
+ }
107
+
108
+ return { success: peerId, failure: null };
109
+ } catch (err) {
110
+ return {
111
+ success: null,
112
+ failure: {
113
+ error: LightPushError.DECODE_FAILED,
114
+ peerId: peerId
115
+ }
116
+ };
117
+ }
118
+ }
119
+
120
+ private static handleV2Response(
121
+ bytes: Uint8ArrayList,
122
+ peerId: PeerId
123
+ ): LightPushCoreResult {
124
+ let response: import("@waku/proto").PushResponse | undefined;
125
+ try {
126
+ const decodedRpc = PushRpcV2.decode(bytes);
127
+ response = decodedRpc.response;
128
+ } catch (err) {
129
+ return {
130
+ success: null,
131
+ failure: {
132
+ error: LightPushError.DECODE_FAILED,
133
+ peerId: peerId
134
+ }
135
+ };
136
+ }
137
+
138
+ if (!response) {
139
+ return {
140
+ success: null,
141
+ failure: {
142
+ error: LightPushError.NO_RESPONSE,
143
+ peerId: peerId
144
+ }
145
+ };
146
+ }
147
+
148
+ if (isRLNResponseError(response.info)) {
149
+ log.error("Remote peer fault: RLN generation");
150
+ return {
151
+ success: null,
152
+ failure: {
153
+ error: LightPushError.RLN_PROOF_GENERATION,
154
+ peerId: peerId
155
+ }
156
+ };
157
+ }
158
+
159
+ if (!response.isSuccess) {
160
+ log.error("Remote peer rejected the message: ", response.info);
161
+ return {
162
+ success: null,
163
+ failure: {
164
+ error: LightPushError.REMOTE_PEER_REJECTED,
165
+ peerId: peerId
166
+ }
167
+ };
168
+ }
169
+
170
+ return { success: peerId, failure: null };
171
+ }
172
+ }
173
+
174
+ function createV2Rpc(
175
+ message: WakuMessage,
176
+ pubsubTopic: string
177
+ ): VersionedPushRpc {
178
+ const v2Rpc = PushRpcV2.createRequest(message, pubsubTopic);
179
+ return Object.assign(v2Rpc, { version: "v2" as const });
180
+ }
181
+
182
+ function createV3Rpc(
183
+ message: WakuMessage,
184
+ pubsubTopic: string
185
+ ): VersionedPushRpc {
186
+ if (!message.timestamp) {
187
+ message.timestamp = BigInt(Date.now()) * BigInt(1_000_000);
188
+ }
189
+
190
+ const v3Rpc = PushRpc.createRequest(message, pubsubTopic);
191
+ return Object.assign(v3Rpc, { version: "v3" as const });
192
+ }
@@ -2,14 +2,14 @@ import { proto_lightpush as proto } from "@waku/proto";
2
2
  import type { Uint8ArrayList } from "uint8arraylist";
3
3
  import { v4 as uuid } from "uuid";
4
4
 
5
- export class PushRpc {
5
+ export class PushRpcV2 {
6
6
  public constructor(public proto: proto.PushRpc) {}
7
7
 
8
8
  public static createRequest(
9
9
  message: proto.WakuMessage,
10
10
  pubsubTopic: string
11
- ): PushRpc {
12
- return new PushRpc({
11
+ ): PushRpcV2 {
12
+ return new PushRpcV2({
13
13
  requestId: uuid(),
14
14
  request: {
15
15
  message: message,
@@ -19,9 +19,9 @@ export class PushRpc {
19
19
  });
20
20
  }
21
21
 
22
- public static decode(bytes: Uint8ArrayList): PushRpc {
22
+ public static decode(bytes: Uint8ArrayList): PushRpcV2 {
23
23
  const res = proto.PushRpc.decode(bytes);
24
- return new PushRpc(res);
24
+ return new PushRpcV2(res);
25
25
  }
26
26
 
27
27
  public encode(): Uint8Array {
@@ -0,0 +1,162 @@
1
+ import { proto_lightpush as proto } from "@waku/proto";
2
+ import type { Uint8ArrayList } from "uint8arraylist";
3
+ import { v4 as uuid } from "uuid";
4
+
5
+ /**
6
+ * LightPush v3 protocol RPC handler.
7
+ * Implements the v3 message format with correct field numbers:
8
+ * - requestId: 1
9
+ * - pubsubTopic: 20
10
+ * - message: 21
11
+ */
12
+ export class PushRpc {
13
+ public constructor(
14
+ public proto: proto.LightPushRequestV3 | proto.LightPushResponseV3
15
+ ) {}
16
+
17
+ /**
18
+ * Create a v3 request message with proper field numbering
19
+ */
20
+ public static createRequest(
21
+ message: proto.WakuMessage,
22
+ pubsubTopic: string
23
+ ): PushRpc {
24
+ return new PushRpc({
25
+ requestId: uuid(),
26
+ pubsubTopic: pubsubTopic,
27
+ message: message
28
+ });
29
+ }
30
+
31
+ /**
32
+ * Create a v3 response message with status code handling
33
+ */
34
+ public static createResponse(
35
+ requestId: string,
36
+ statusCode: number,
37
+ statusDesc?: string,
38
+ relayPeerCount?: number
39
+ ): PushRpc {
40
+ return new PushRpc({
41
+ requestId,
42
+ statusCode,
43
+ statusDesc,
44
+ relayPeerCount
45
+ });
46
+ }
47
+
48
+ /**
49
+ * Decode v3 request message
50
+ */
51
+ public static decodeRequest(bytes: Uint8ArrayList): PushRpc {
52
+ const res = proto.LightPushRequestV3.decode(bytes);
53
+ return new PushRpc(res);
54
+ }
55
+
56
+ /**
57
+ * Decode v3 response message
58
+ */
59
+ public static decodeResponse(bytes: Uint8ArrayList): PushRpc {
60
+ const res = proto.LightPushResponseV3.decode(bytes);
61
+ return new PushRpc(res);
62
+ }
63
+
64
+ /**
65
+ * Encode message to bytes
66
+ */
67
+ public encode(): Uint8Array {
68
+ if (this.isRequest()) {
69
+ return proto.LightPushRequestV3.encode(
70
+ this.proto as proto.LightPushRequestV3
71
+ );
72
+ } else {
73
+ return proto.LightPushResponseV3.encode(
74
+ this.proto as proto.LightPushResponseV3
75
+ );
76
+ }
77
+ }
78
+
79
+ /**
80
+ * Get request data (if this is a request message)
81
+ */
82
+ public get request(): proto.LightPushRequestV3 | undefined {
83
+ return this.isRequest()
84
+ ? (this.proto as proto.LightPushRequestV3)
85
+ : undefined;
86
+ }
87
+
88
+ /**
89
+ * Get response data (if this is a response message)
90
+ */
91
+ public get response(): proto.LightPushResponseV3 | undefined {
92
+ return this.isResponse()
93
+ ? (this.proto as proto.LightPushResponseV3)
94
+ : undefined;
95
+ }
96
+
97
+ /**
98
+ * Get the request ID
99
+ */
100
+ public get requestId(): string {
101
+ return this.proto.requestId;
102
+ }
103
+
104
+ /**
105
+ * Get the pubsub topic (only available in requests)
106
+ */
107
+ public get pubsubTopic(): string | undefined {
108
+ return this.isRequest()
109
+ ? (this.proto as proto.LightPushRequestV3).pubsubTopic
110
+ : undefined;
111
+ }
112
+
113
+ /**
114
+ * Get the message (only available in requests)
115
+ */
116
+ public get message(): proto.WakuMessage | undefined {
117
+ return this.isRequest()
118
+ ? (this.proto as proto.LightPushRequestV3).message
119
+ : undefined;
120
+ }
121
+
122
+ /**
123
+ * Get the status code (only available in responses)
124
+ */
125
+ public get statusCode(): number | undefined {
126
+ return this.isResponse()
127
+ ? (this.proto as proto.LightPushResponseV3).statusCode
128
+ : undefined;
129
+ }
130
+
131
+ /**
132
+ * Get the status description (only available in responses)
133
+ */
134
+ public get statusDesc(): string | undefined {
135
+ return this.isResponse()
136
+ ? (this.proto as proto.LightPushResponseV3).statusDesc
137
+ : undefined;
138
+ }
139
+
140
+ /**
141
+ * Get the relay peer count (only available in responses)
142
+ */
143
+ public get relayPeerCount(): number | undefined {
144
+ return this.isResponse()
145
+ ? (this.proto as proto.LightPushResponseV3).relayPeerCount
146
+ : undefined;
147
+ }
148
+
149
+ /**
150
+ * Check if this is a request message
151
+ */
152
+ private isRequest(): boolean {
153
+ return "pubsubTopic" in this.proto && "message" in this.proto;
154
+ }
155
+
156
+ /**
157
+ * Check if this is a response message
158
+ */
159
+ private isResponse(): boolean {
160
+ return "statusCode" in this.proto;
161
+ }
162
+ }
@@ -27,7 +27,7 @@ class Metadata implements IMetadata {
27
27
  private readonly libp2pComponents: Libp2pComponents;
28
28
  protected handshakesConfirmed: Map<PeerIdStr, ShardInfo> = new Map();
29
29
 
30
- public readonly multicodec = MetadataCodec;
30
+ public readonly multicodec = [MetadataCodec];
31
31
 
32
32
  public constructor(
33
33
  public clusterId: ClusterId,
@@ -29,7 +29,7 @@ export const StoreCodec = "/vac/waku/store-query/3.0.0";
29
29
  export class StoreCore {
30
30
  private readonly streamManager: StreamManager;
31
31
 
32
- public readonly multicodec = StoreCodec;
32
+ public readonly multicodec = [StoreCodec];
33
33
 
34
34
  public constructor(libp2p: Libp2p) {
35
35
  this.streamManager = new StreamManager(StoreCodec, libp2p.components);
@@ -13,7 +13,7 @@ export class StreamManager {
13
13
  private streamPool: Map<string, Promise<void>> = new Map();
14
14
 
15
15
  public constructor(
16
- private multicodec: string,
16
+ public multicodec: string,
17
17
  private readonly libp2p: Libp2pComponents
18
18
  ) {
19
19
  this.log = new Logger(`stream-manager:${multicodec}`);