diff --git a/packages/core/src/lib/filter/v2/index.ts b/packages/core/src/lib/filter/v2/index.ts index b8f4a1758e..09b486fd73 100644 --- a/packages/core/src/lib/filter/v2/index.ts +++ b/packages/core/src/lib/filter/v2/index.ts @@ -1,4 +1,5 @@ import type { Libp2p } from "@libp2p/interface-libp2p"; +import { PeerId } from "@libp2p/interface-peer-id"; import type { Peer } from "@libp2p/interface-peer-store"; import { IncomingStreamData } from "@libp2p/interface-registrar"; import type { @@ -143,12 +144,12 @@ class FilterV2 extends BaseProtocol implements IFilterV2 { }; } - public async unsubscribeAll(): Promise { + public async unsubscribeAll(peerId: PeerId): Promise { const { pubSubTopic = DefaultPubSubTopic } = this.options; const request = FilterSubscribeRpc.createUnsubscribeAllRequest(pubSubTopic); - const peer = await this.getPeer(); + const peer = await this.getPeer(peerId); const stream = await this.newStream(peer); try { @@ -177,12 +178,12 @@ class FilterV2 extends BaseProtocol implements IFilterV2 { } } - public async ping(): Promise { + public async ping(peerId: PeerId): Promise { const { pubSubTopic = DefaultPubSubTopic } = this.options; const request = FilterSubscribeRpc.createSubscriberPingRequest(pubSubTopic); - const peer = await this.getPeer(); + const peer = await this.getPeer(peerId); const stream = await this.newStream(peer); try { diff --git a/packages/interfaces/src/receiver.ts b/packages/interfaces/src/receiver.ts index 2cc07f2055..f2ca75127f 100644 --- a/packages/interfaces/src/receiver.ts +++ b/packages/interfaces/src/receiver.ts @@ -1,3 +1,5 @@ +import { PeerId } from "@libp2p/interface-peer-id"; + import type { IDecodedMessage, IDecoder } from "./message.js"; import type { Callback, ProtocolOptions } from "./protocols.js"; @@ -17,6 +19,6 @@ export interface IReceiverV1 { } export interface IReceiverV2 extends IReceiverV1 { - ping: () => Promise; - unsubscribeAll: () => Promise; + ping: (peerId: PeerId) => Promise; + unsubscribeAll: (peerId: PeerId) => Promise; } diff --git a/packages/tests/tests/filter_v2.node.spec.ts b/packages/tests/tests/filter_v2.node.spec.ts index c3a96b1a15..1532c28da5 100644 --- a/packages/tests/tests/filter_v2.node.spec.ts +++ b/packages/tests/tests/filter_v2.node.spec.ts @@ -172,14 +172,14 @@ describe("Waku Filter: V2", () => { const callback = (): void => { messageCount++; }; - await waku.filter.subscribe([TestDecoder], callback); + const peerId = await waku.filter.subscribe([TestDecoder], callback); await delay(200); await waku.lightPush.send(TestEncoder, { payload: utf8ToBytes("This should be received"), }); await delay(100); - await waku.filter.ping(); + await waku.filter.ping(peerId); await waku.lightPush.send(TestEncoder, { payload: utf8ToBytes("This should be received"), });