mirror of
https://github.com/logos-messaging/logos-delivery-js.git
synced 2026-03-11 04:03:07 +00:00
* chore: decouple `Filter` between `core` and `sdk` moves `SubscriptionManager` to `sdk` side * chore: update package dependencies also update peer deps in sdk * chore: update imports * chore: update tests * chore(side-change): update lightpush * chore: update size-limit import * chore(sdk): update dependencies
58 lines
1.5 KiB
TypeScript
58 lines
1.5 KiB
TypeScript
import { type Libp2pComponents, type LightNode } from "@waku/interfaces";
|
|
|
|
import { wakuFilter } from "../protocols/filter.js";
|
|
import { wakuLightPush } from "../protocols/light_push.js";
|
|
import { wakuStore } from "../protocols/store.js";
|
|
import { createLibp2pAndUpdateOptions } from "../utils/libp2p.js";
|
|
import { CreateWakuNodeOptions, WakuNode, WakuOptions } from "../waku.js";
|
|
|
|
export { Libp2pComponents };
|
|
|
|
/**
|
|
* Create a Waku node configured to use autosharding or static sharding.
|
|
*/
|
|
export async function createNode(
|
|
options: CreateWakuNodeOptions = { pubsubTopics: [] }
|
|
): Promise<LightNode> {
|
|
if (!options.shardInfo) {
|
|
throw new Error("Shard info must be set");
|
|
}
|
|
|
|
const libp2p = await createLibp2pAndUpdateOptions(options);
|
|
|
|
const store = wakuStore(options);
|
|
const lightPush = wakuLightPush(options);
|
|
const filter = wakuFilter(options);
|
|
|
|
return new WakuNode(
|
|
options as WakuOptions,
|
|
libp2p,
|
|
store,
|
|
lightPush,
|
|
filter
|
|
) as LightNode;
|
|
}
|
|
|
|
/**
|
|
* Create a Waku node that uses Waku Light Push, Filter and Store to send and
|
|
* receive messages, enabling low resource consumption.
|
|
* Uses Waku Filter V2 by default.
|
|
*/
|
|
export async function createLightNode(
|
|
options: CreateWakuNodeOptions = {}
|
|
): Promise<LightNode> {
|
|
const libp2p = await createLibp2pAndUpdateOptions(options);
|
|
|
|
const store = wakuStore(options);
|
|
const lightPush = wakuLightPush(options);
|
|
const filter = wakuFilter(options);
|
|
|
|
return new WakuNode(
|
|
options as WakuOptions,
|
|
libp2p,
|
|
store,
|
|
lightPush,
|
|
filter
|
|
) as LightNode;
|
|
}
|