From 450e0ba3850f8d145056b912ab48a4058c3af29b Mon Sep 17 00:00:00 2001 From: danisharora099 Date: Mon, 27 Nov 2023 18:23:34 +0530 Subject: [PATCH] filter: createSubscription takes shardInfo instead of pubsubTopicStr --- packages/core/src/lib/filter/index.ts | 8 +++++++- packages/interfaces/src/filter.ts | 8 ++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/packages/core/src/lib/filter/index.ts b/packages/core/src/lib/filter/index.ts index 0b8f3377f7..16b53deba1 100644 --- a/packages/core/src/lib/filter/index.ts +++ b/packages/core/src/lib/filter/index.ts @@ -14,12 +14,14 @@ import type { PeerIdStr, ProtocolCreateOptions, PubsubTopic, + SingleTopicShardInfo, Unsubscribe } from "@waku/interfaces"; import { WakuMessage } from "@waku/proto"; import { ensurePubsubTopicIsConfigured, groupByContentTopic, + singleTopicShardInfoToPubsubTopic, toAsyncIterator } from "@waku/utils"; import { Logger } from "@waku/utils"; @@ -289,8 +291,12 @@ class Filter extends BaseProtocol implements IReceiver { } async createSubscription( - pubsubTopic: string = DefaultPubsubTopic + pubsubTopicShardInfo?: SingleTopicShardInfo ): Promise { + const pubsubTopic = pubsubTopicShardInfo + ? singleTopicShardInfoToPubsubTopic(pubsubTopicShardInfo) + : DefaultPubsubTopic; + ensurePubsubTopicIsConfigured(pubsubTopic, this.pubsubTopics); //TODO: get a relevant peer for the topic/shard diff --git a/packages/interfaces/src/filter.ts b/packages/interfaces/src/filter.ts index 34dad0f87c..580c14cdb9 100644 --- a/packages/interfaces/src/filter.ts +++ b/packages/interfaces/src/filter.ts @@ -1,6 +1,10 @@ import type { PeerId } from "@libp2p/interface/peer-id"; -import type { IDecodedMessage, IDecoder } from "./message.js"; +import type { + IDecodedMessage, + IDecoder, + SingleTopicShardInfo +} from "./message.js"; import type { ContentTopic } from "./misc.js"; import type { Callback, IBaseProtocol } from "./protocols.js"; import type { IReceiver } from "./receiver.js"; @@ -25,7 +29,7 @@ export interface IFilterSubscription { export type IFilter = IReceiver & IBaseProtocol & { createSubscription( - pubsubTopic?: string, + pubsubTopicShardInfo?: SingleTopicShardInfo, peerId?: PeerId ): Promise; };