Skip to content

Commit

Permalink
chore: remove relay from sdk package (#2040)
Browse files Browse the repository at this point in the history
* remove full node

* remove relay from sdk

* comment node counter check

* try using logline

* up comment
  • Loading branch information
weboko authored Aug 31, 2024
1 parent f9361bf commit 5cfe932
Show file tree
Hide file tree
Showing 27 changed files with 446 additions and 483 deletions.
97 changes: 48 additions & 49 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
"packages/message-hash",
"packages/enr",
"packages/core",
"packages/relay",
"packages/discovery",
"packages/message-encryption",
"packages/sdk",
"packages/relay",
"packages/tests",
"packages/browser-tests",
"packages/build-utils",
Expand Down
7 changes: 0 additions & 7 deletions packages/interfaces/src/waku.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,3 @@ export interface RelayNode extends Waku {
filter: undefined;
lightPush: undefined;
}

export interface FullNode extends Waku {
relay: IRelay;
store: IStoreSDK;
filter: IFilterSDK;
lightPush: ILightPushSDK;
}
1 change: 1 addition & 0 deletions packages/relay/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"@chainsafe/libp2p-gossipsub": "^13.1.0",
"@noble/hashes": "^1.3.2",
"@waku/core": "0.0.31",
"@waku/sdk": "0.0.27",
"@waku/interfaces": "0.0.26",
"@waku/proto": "0.0.8",
"@waku/utils": "0.0.19",
Expand Down
44 changes: 44 additions & 0 deletions packages/relay/src/create.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
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;
}
Loading

0 comments on commit 5cfe932

Please sign in to comment.