Sasha 5cfe9327b6
chore: remove relay from sdk package (#2040)
* remove full node

* remove relay from sdk

* comment node counter check

* try using logline

* up comment
2024-08-31 15:18:51 +02:00

45 lines
1.3 KiB
TypeScript

import type { RelayNode } from "@waku/interfaces";
import {
createLibp2pAndUpdateOptions,
CreateWakuNodeOptions,
WakuNode,
WakuOptions
} from "@waku/sdk";
import { RelayCreateOptions, wakuGossipSub, wakuRelay } from "./relay.js";
/**
* Create a Waku node that uses Waku Relay to send and receive messages,
* enabling some privacy preserving properties.
* * @remarks
* This function creates a Relay Node using the Waku Relay protocol.
* While it is technically possible to use this function in a browser environment,
* it is not recommended due to potential performance issues and limited browser capabilities.
* If you are developing a browser-based application, consider alternative approaches like creating a Light Node
* or use this function with caution.
*/
export async function createRelayNode(
options: CreateWakuNodeOptions & Partial<RelayCreateOptions>
): Promise<RelayNode> {
options = {
...options,
libp2p: {
...options.libp2p,
services: {
pubsub: wakuGossipSub(options)
}
}
};
const { libp2p, pubsubTopics } = await createLibp2pAndUpdateOptions(options);
const relay = wakuRelay(pubsubTopics || [])(libp2p);
return new WakuNode(
pubsubTopics,
options as WakuOptions,
libp2p,
{},
relay
) as RelayNode;
}