Skip to content

Commit

Permalink
filter: createSubscription takes shardInfo instead of pubsubTopicStr
Browse files Browse the repository at this point in the history
  • Loading branch information
danisharora099 committed Nov 27, 2023
1 parent ab4831c commit 450e0ba
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
8 changes: 7 additions & 1 deletion packages/core/src/lib/filter/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -289,8 +291,12 @@ class Filter extends BaseProtocol implements IReceiver {
}

async createSubscription(
pubsubTopic: string = DefaultPubsubTopic
pubsubTopicShardInfo?: SingleTopicShardInfo
): Promise<Subscription> {
const pubsubTopic = pubsubTopicShardInfo
? singleTopicShardInfoToPubsubTopic(pubsubTopicShardInfo)
: DefaultPubsubTopic;

ensurePubsubTopicIsConfigured(pubsubTopic, this.pubsubTopics);

//TODO: get a relevant peer for the topic/shard
Expand Down
8 changes: 6 additions & 2 deletions packages/interfaces/src/filter.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -25,7 +29,7 @@ export interface IFilterSubscription {
export type IFilter = IReceiver &
IBaseProtocol & {
createSubscription(
pubsubTopic?: string,
pubsubTopicShardInfo?: SingleTopicShardInfo,
peerId?: PeerId
): Promise<IFilterSubscription>;
};

0 comments on commit 450e0ba

Please sign in to comment.