feat: create a monitor per subscription

This commit is contained in:
Danish Arora 2024-09-10 16:25:04 +05:30
parent 777f497d13
commit b95436576e
No known key found for this signature in database
GPG Key ID: 1C6EF37CDAE1426E
2 changed files with 9 additions and 5 deletions

View File

@ -27,6 +27,7 @@ import {
} from "@waku/utils";
import { BaseProtocolSDK } from "../base_protocol";
import { MessageReliabilityMonitor } from "../message_reliability_monitor";
import { SubscriptionManager } from "./subscription_manager";
@ -203,9 +204,9 @@ class FilterSDK extends BaseProtocolSDK implements IFilterSDK {
this.connectedPeers.map((peer) => peer.id.toString())
);
const subscription =
this.getActiveSubscription(pubsubTopic) ??
this.setActiveSubscription(
let subscription = this.getActiveSubscription(pubsubTopic);
if (!subscription) {
subscription = this.setActiveSubscription(
pubsubTopic,
new SubscriptionManager(
pubsubTopic,
@ -216,6 +217,9 @@ class FilterSDK extends BaseProtocolSDK implements IFilterSDK {
)
);
new MessageReliabilityMonitor(this, subscription);
}
return {
error: null,
subscription

View File

@ -18,7 +18,7 @@ import { Logger } from "@waku/utils";
import { wakuFilter } from "./protocols/filter/index.js";
import { wakuLightPush } from "./protocols/light_push.js";
import { MessageReliabilityMonitor } from "./protocols/message_reliability_monitor.js";
import { MessageReliabilityManager } from "./protocols/message_reliability_monitor.js";
import { wakuStore } from "./protocols/store.js";
export const DefaultPingKeepAliveValueSecs = 5 * 60;
@ -116,7 +116,7 @@ export class WakuNode implements Waku {
if (protocolsEnabled.filter) {
const filter = wakuFilter(this.connectionManager);
this.filter = filter(libp2p);
new MessageReliabilityMonitor(this.filter);
new MessageReliabilityManager(this.filter);
}
log.info(