mirror of
https://github.com/logos-messaging/js-waku.git
synced 2026-01-04 06:43: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(
|
public constructor(
|
||||||
private handleIncomingMessage: IncomingMessageHandler,
|
private handleIncomingMessage: IncomingMessageHandler,
|
||||||
libp2p: Libp2p
|
private libp2p: Libp2p
|
||||||
) {
|
) {
|
||||||
this.streamManager = new StreamManager(
|
this.streamManager = new StreamManager(
|
||||||
FilterCodecs.SUBSCRIBE,
|
FilterCodecs.SUBSCRIBE,
|
||||||
libp2p.components
|
libp2p.components
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
libp2p
|
public async start(): Promise<void> {
|
||||||
.handle(FilterCodecs.PUSH, this.onRequest.bind(this), {
|
try {
|
||||||
|
await this.libp2p.handle(FilterCodecs.PUSH, this.onRequest.bind(this), {
|
||||||
maxInboundStreams: 100
|
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(
|
public async subscribe(
|
||||||
|
|||||||
@ -4,6 +4,16 @@ import type { Callback } from "./protocols.js";
|
|||||||
export type IFilter = {
|
export type IFilter = {
|
||||||
readonly multicodec: string;
|
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.
|
* Subscribes to messages that match the filtering criteria defined in the specified decoders.
|
||||||
* Executes a callback upon receiving each message.
|
* Executes a callback upon receiving each message.
|
||||||
|
|||||||
@ -45,6 +45,14 @@ export class Filter implements IFilter {
|
|||||||
return this.protocol.multicodec;
|
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 {
|
public unsubscribeAll(): void {
|
||||||
for (const subscription of this.subscriptions.values()) {
|
for (const subscription of this.subscriptions.values()) {
|
||||||
subscription.stop();
|
subscription.stop();
|
||||||
|
|||||||
@ -216,6 +216,7 @@ export class WakuNode implements IWaku {
|
|||||||
this._nodeStateLock = true;
|
this._nodeStateLock = true;
|
||||||
|
|
||||||
await this.libp2p.start();
|
await this.libp2p.start();
|
||||||
|
await this.filter?.start();
|
||||||
this.connectionManager.start();
|
this.connectionManager.start();
|
||||||
this.peerManager.start();
|
this.peerManager.start();
|
||||||
this.healthIndicator.start();
|
this.healthIndicator.start();
|
||||||
@ -231,6 +232,7 @@ export class WakuNode implements IWaku {
|
|||||||
this._nodeStateLock = true;
|
this._nodeStateLock = true;
|
||||||
|
|
||||||
this.lightPush?.stop();
|
this.lightPush?.stop();
|
||||||
|
await this.filter?.stop();
|
||||||
this.healthIndicator.stop();
|
this.healthIndicator.stop();
|
||||||
this.peerManager.stop();
|
this.peerManager.stop();
|
||||||
this.connectionManager.stop();
|
this.connectionManager.stop();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user