Merge branch 'master' into codex/enforce-folder-structure-with-eslint

This commit is contained in:
Sasha 2025-09-02 23:56:07 +02:00 committed by GitHub
commit 874c171da4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 36 additions and 6 deletions

View File

@ -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(

View File

@ -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.

View File

@ -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();

View File

@ -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();