Minor fixes

This commit is contained in:
Franck Royer 2022-05-26 15:00:22 +10:00
parent f7613febed
commit e5dde6f9e9
No known key found for this signature in database
GPG Key ID: A82ED75A8DFC50A4
1 changed files with 11 additions and 4 deletions

View File

@ -20,7 +20,7 @@ type FilterSubscriptionOpts = {
/**
* The Pubsub topic for the subscription
*/
topic?: string;
pubsubTopic?: string;
/**
* Optionally specify a PeerId for the subscription. If not included, will use a random peer.
*/
@ -65,7 +65,7 @@ export class WakuFilter {
opts: FilterSubscriptionOpts,
callback: FilterCallback
): Promise<UnsubscribeFunction> {
const topic = opts.topic || DefaultPubSubTopic;
const topic = opts.pubsubTopic || DefaultPubSubTopic;
const contentFilters = opts.contentTopics.map((contentTopic) => ({
contentTopic,
}));
@ -76,13 +76,20 @@ export class WakuFilter {
true
);
const peer = await this.getPeer();
const peer = await this.getPeer(opts.peerId);
const stream = await this.newStream(peer);
try {
await pipe([request.encode()], lp.encode(), stream);
} catch (e) {
log("Error subscribing", e);
log(
"Error subscribing to peer ",
peer.id.toB58String(),
"for content topics",
opts.contentTopics,
": ",
e
);
throw e;
}