@waku/core 0.0.37-987c6cd.0 → 0.0.37-c24842a.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,16 +1,16 @@
1
1
  import type { PeerId } from "@libp2p/interface";
2
2
  import { IncomingStreamData } from "@libp2p/interface";
3
3
  import {
4
+ type ClusterId,
4
5
  type IMetadata,
5
6
  type Libp2pComponents,
6
7
  type MetadataQueryResult,
7
8
  type PeerIdStr,
8
9
  ProtocolError,
9
- PubsubTopic,
10
10
  type ShardInfo
11
11
  } from "@waku/interfaces";
12
12
  import { proto_metadata } from "@waku/proto";
13
- import { encodeRelayShard, Logger, pubsubTopicsToShardInfo } from "@waku/utils";
13
+ import { encodeRelayShard, Logger } from "@waku/utils";
14
14
  import all from "it-all";
15
15
  import * as lp from "it-length-prefixed";
16
16
  import { pipe } from "it-pipe";
@@ -30,7 +30,7 @@ class Metadata implements IMetadata {
30
30
  public readonly multicodec = MetadataCodec;
31
31
 
32
32
  public constructor(
33
- public pubsubTopics: PubsubTopic[],
33
+ public clusterId: ClusterId,
34
34
  libp2p: Libp2pComponents
35
35
  ) {
36
36
  this.streamManager = new StreamManager(MetadataCodec, libp2p);
@@ -44,9 +44,10 @@ class Metadata implements IMetadata {
44
44
  * Make a metadata query to a peer
45
45
  */
46
46
  public async query(peerId: PeerId): Promise<MetadataQueryResult> {
47
- const request = proto_metadata.WakuMetadataRequest.encode(
48
- pubsubTopicsToShardInfo(this.pubsubTopics)
49
- );
47
+ const request = proto_metadata.WakuMetadataRequest.encode({
48
+ clusterId: this.clusterId,
49
+ shards: [] // Only services node need to provide shards
50
+ });
50
51
 
51
52
  const peer = await this.libp2pComponents.peerStore.get(peerId);
52
53
  if (!peer) {
@@ -112,9 +113,10 @@ class Metadata implements IMetadata {
112
113
  private async onRequest(streamData: IncomingStreamData): Promise<void> {
113
114
  try {
114
115
  const { stream, connection } = streamData;
115
- const encodedShardInfo = proto_metadata.WakuMetadataResponse.encode(
116
- pubsubTopicsToShardInfo(this.pubsubTopics)
117
- );
116
+ const encodedShardInfo = proto_metadata.WakuMetadataResponse.encode({
117
+ clusterId: this.clusterId,
118
+ shards: [] // Only service nodes need to provide shards
119
+ });
118
120
 
119
121
  const encodedResponse = await pipe(
120
122
  [encodedShardInfo],
@@ -178,8 +180,7 @@ class Metadata implements IMetadata {
178
180
  }
179
181
 
180
182
  export function wakuMetadata(
181
- pubsubTopics: PubsubTopic[]
183
+ clusterId: ClusterId
182
184
  ): (components: Libp2pComponents) => IMetadata {
183
- return (components: Libp2pComponents) =>
184
- new Metadata(pubsubTopics, components);
185
+ return (components: Libp2pComponents) => new Metadata(clusterId, components);
185
186
  }