mirror of
https://github.com/logos-messaging/js-waku.git
synced 2026-01-02 13:53:12 +00:00
Merge branch 'master' into codex/enforce-folder-structure-with-eslint
This commit is contained in:
commit
874c171da4
@ -42,20 +42,30 @@ export class FilterCore {
|
||||
|
||||
public constructor(
|
||||
private handleIncomingMessage: IncomingMessageHandler,
|
||||
libp2p: Libp2p
|
||||
private libp2p: Libp2p
|
||||
) {
|
||||
this.streamManager = new StreamManager(
|
||||
FilterCodecs.SUBSCRIBE,
|
||||
libp2p.components
|
||||
);
|
||||
}
|
||||
|
||||
libp2p
|
||||
.handle(FilterCodecs.PUSH, this.onRequest.bind(this), {
|
||||
public async start(): Promise<void> {
|
||||
try {
|
||||
await this.libp2p.handle(FilterCodecs.PUSH, this.onRequest.bind(this), {
|
||||
maxInboundStreams: 100
|
||||
})
|
||||
.catch((e) => {
|
||||
log.error("Failed to register ", FilterCodecs.PUSH, e);
|
||||
});
|
||||
} catch (e) {
|
||||
log.error("Failed to register ", FilterCodecs.PUSH, e);
|
||||
}
|
||||
}
|
||||
|
||||
public async stop(): Promise<void> {
|
||||
try {
|
||||
await this.libp2p.unhandle(FilterCodecs.PUSH);
|
||||
} catch (e) {
|
||||
log.error("Failed to unregister ", FilterCodecs.PUSH, e);
|
||||
}
|
||||
}
|
||||
|
||||
public async subscribe(
|
||||
|
||||
@ -4,6 +4,16 @@ import type { Callback } from "./protocols.js";
|
||||
export type IFilter = {
|
||||
readonly multicodec: string;
|
||||
|
||||
/**
|
||||
* Starts the filter protocol.
|
||||
*/
|
||||
start(): Promise<void>;
|
||||
|
||||
/**
|
||||
* Stops the filter protocol.
|
||||
*/
|
||||
stop(): Promise<void>;
|
||||
|
||||
/**
|
||||
* Subscribes to messages that match the filtering criteria defined in the specified decoders.
|
||||
* Executes a callback upon receiving each message.
|
||||
|
||||
@ -45,6 +45,14 @@ export class Filter implements IFilter {
|
||||
return this.protocol.multicodec;
|
||||
}
|
||||
|
||||
public async start(): Promise<void> {
|
||||
await this.protocol.start();
|
||||
}
|
||||
|
||||
public async stop(): Promise<void> {
|
||||
await this.protocol.stop();
|
||||
}
|
||||
|
||||
public unsubscribeAll(): void {
|
||||
for (const subscription of this.subscriptions.values()) {
|
||||
subscription.stop();
|
||||
|
||||
@ -216,6 +216,7 @@ export class WakuNode implements IWaku {
|
||||
this._nodeStateLock = true;
|
||||
|
||||
await this.libp2p.start();
|
||||
await this.filter?.start();
|
||||
this.connectionManager.start();
|
||||
this.peerManager.start();
|
||||
this.healthIndicator.start();
|
||||
@ -231,6 +232,7 @@ export class WakuNode implements IWaku {
|
||||
this._nodeStateLock = true;
|
||||
|
||||
this.lightPush?.stop();
|
||||
await this.filter?.stop();
|
||||
this.healthIndicator.stop();
|
||||
this.peerManager.stop();
|
||||
this.connectionManager.stop();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user