-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move createRelayNode under an explicit export
- Loading branch information
1 parent
4bdd7ee
commit 8d8244e
Showing
12 changed files
with
71 additions
and
53 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { WakuNode, WakuOptions } from "@waku/core"; | ||
import type { ProtocolCreateOptions, RelayNode } from "@waku/interfaces"; | ||
import { RelayCreateOptions, wakuGossipSub, wakuRelay } from "@waku/relay"; | ||
|
||
import { defaultLibp2p, defaultPeerDiscoveries } from "../create.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?: ProtocolCreateOptions & WakuOptions & Partial<RelayCreateOptions> | ||
): Promise<RelayNode> { | ||
options = options ?? {}; | ||
|
||
const libp2pOptions = options?.libp2p ?? {}; | ||
const peerDiscovery = libp2pOptions.peerDiscovery ?? []; | ||
if (options?.defaultBootstrap) { | ||
peerDiscovery.push(...defaultPeerDiscoveries()); | ||
Object.assign(libp2pOptions, { peerDiscovery }); | ||
} | ||
|
||
const libp2p = await defaultLibp2p( | ||
options.shardInfo, | ||
wakuGossipSub(options), | ||
libp2pOptions, | ||
options?.userAgent | ||
); | ||
|
||
const relay = wakuRelay(options); | ||
|
||
return new WakuNode( | ||
options, | ||
libp2p, | ||
options.shardInfo, | ||
undefined, | ||
undefined, | ||
undefined, | ||
relay | ||
) as RelayNode; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters