mirror of https://github.com/waku-org/js-waku.git
remove WakuOptions and use only ProtocolCreateOptions
This commit is contained in:
parent
5147ee328c
commit
7eb67ff751
|
@ -24,17 +24,11 @@ export type NetworkConfig = StaticSharding | AutoSharding;
|
|||
|
||||
export type ProtocolCreateOptions = {
|
||||
/**
|
||||
* Configuration for determining the network in use.
|
||||
* Set the user agent string to be used in identification of the node.
|
||||
*
|
||||
* If using Static Sharding:
|
||||
* Default value is configured for The Waku Network.
|
||||
* The format to specify a shard is: clusterId: number, shards: number[]
|
||||
* To learn more about the sharding specification, see [Relay Sharding](https://rfc.vac.dev/spec/51/).
|
||||
*
|
||||
* If using Auto Sharding:
|
||||
* See [Waku v2 Topic Usage Recommendations](https://github.com/vacp2p/rfc-index/blob/main/waku/informational/23/topics.md#content-topics) for details.
|
||||
* You cannot add or remove content topics after initialization of the node.
|
||||
* @default "js-waku"
|
||||
*/
|
||||
userAgent?: string;
|
||||
|
||||
/**
|
||||
* Configuration for determining the network in use.
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
import type { RelayNode } from "@waku/interfaces";
|
||||
import {
|
||||
createLibp2pAndUpdateOptions,
|
||||
CreateWakuNodeOptions,
|
||||
WakuNode,
|
||||
WakuOptions
|
||||
} from "@waku/sdk";
|
||||
import type { ProtocolCreateOptions, RelayNode } from "@waku/interfaces";
|
||||
import { createLibp2pAndUpdateOptions, WakuNode } from "@waku/sdk";
|
||||
|
||||
import { RelayCreateOptions, wakuGossipSub, wakuRelay } from "./relay.js";
|
||||
|
||||
|
@ -19,7 +14,7 @@ import { RelayCreateOptions, wakuGossipSub, wakuRelay } from "./relay.js";
|
|||
* or use this function with caution.
|
||||
*/
|
||||
export async function createRelayNode(
|
||||
options: CreateWakuNodeOptions & Partial<RelayCreateOptions>
|
||||
options: ProtocolCreateOptions & Partial<RelayCreateOptions>
|
||||
): Promise<RelayNode> {
|
||||
options = {
|
||||
...options,
|
||||
|
@ -36,7 +31,7 @@ export async function createRelayNode(
|
|||
|
||||
return new WakuNode(
|
||||
pubsubTopics,
|
||||
options as WakuOptions,
|
||||
options as ProtocolCreateOptions,
|
||||
libp2p,
|
||||
{},
|
||||
relay
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { type LightNode } from "@waku/interfaces";
|
||||
import type { LightNode, ProtocolCreateOptions } from "@waku/interfaces";
|
||||
|
||||
import { CreateWakuNodeOptions, WakuNode } from "../waku/index.js";
|
||||
import { WakuNode } from "../waku/index.js";
|
||||
|
||||
import { createLibp2pAndUpdateOptions } from "./libp2p.js";
|
||||
|
||||
|
@ -10,7 +10,7 @@ import { createLibp2pAndUpdateOptions } from "./libp2p.js";
|
|||
* Uses Waku Filter V2 by default.
|
||||
*/
|
||||
export async function createLightNode(
|
||||
options: CreateWakuNodeOptions = {}
|
||||
options: ProtocolCreateOptions = {}
|
||||
): Promise<LightNode> {
|
||||
const { libp2p, pubsubTopics } = await createLibp2pAndUpdateOptions(options);
|
||||
|
||||
|
|
|
@ -12,17 +12,12 @@ import {
|
|||
type IMetadata,
|
||||
type Libp2p,
|
||||
type Libp2pComponents,
|
||||
type ProtocolCreateOptions,
|
||||
PubsubTopic
|
||||
} from "@waku/interfaces";
|
||||
import { derivePubsubTopicsFromNetworkConfig, Logger } from "@waku/utils";
|
||||
import { createLibp2p } from "libp2p";
|
||||
|
||||
import {
|
||||
CreateWakuNodeOptions,
|
||||
DefaultPingMaxInboundStreams,
|
||||
DefaultUserAgent
|
||||
} from "../waku/index.js";
|
||||
|
||||
import { defaultPeerDiscoveries } from "./discovery.js";
|
||||
|
||||
type MetadataService = {
|
||||
|
@ -31,6 +26,9 @@ type MetadataService = {
|
|||
|
||||
const log = new Logger("sdk:create");
|
||||
|
||||
const DefaultUserAgent = "js-waku";
|
||||
const DefaultPingMaxInboundStreams = 10;
|
||||
|
||||
export async function defaultLibp2p(
|
||||
pubsubTopics: PubsubTopic[],
|
||||
options?: Partial<CreateLibp2pOptions>,
|
||||
|
@ -78,7 +76,7 @@ export async function defaultLibp2p(
|
|||
}
|
||||
|
||||
export async function createLibp2pAndUpdateOptions(
|
||||
options: CreateWakuNodeOptions
|
||||
options: ProtocolCreateOptions
|
||||
): Promise<{ libp2p: Libp2p; pubsubTopics: PubsubTopic[] }> {
|
||||
const { networkConfig } = options;
|
||||
const pubsubTopics = derivePubsubTopicsFromNetworkConfig(
|
||||
|
|
|
@ -24,22 +24,8 @@ import { ReliabilityMonitorManager } from "../reliability_monitor/index.js";
|
|||
|
||||
import { waitForRemotePeer } from "./wait_for_remote_peer.js";
|
||||
|
||||
export const DefaultUserAgent = "js-waku";
|
||||
export const DefaultPingMaxInboundStreams = 10;
|
||||
|
||||
const log = new Logger("waku");
|
||||
|
||||
export interface WakuOptions {
|
||||
/**
|
||||
* Set the user agent string to be used in identification of the node.
|
||||
* @default {@link @waku/core.DefaultUserAgent}
|
||||
*/
|
||||
userAgent?: string;
|
||||
}
|
||||
|
||||
export type CreateWakuNodeOptions = ProtocolCreateOptions &
|
||||
Partial<WakuOptions>;
|
||||
|
||||
type ProtocolsEnabled = {
|
||||
filter?: boolean;
|
||||
lightpush?: boolean;
|
||||
|
@ -59,7 +45,7 @@ export class WakuNode implements IWaku {
|
|||
|
||||
public constructor(
|
||||
public readonly pubsubTopics: PubsubTopic[],
|
||||
options: CreateWakuNodeOptions,
|
||||
options: ProtocolCreateOptions,
|
||||
libp2p: Libp2p,
|
||||
protocolsEnabled: ProtocolsEnabled,
|
||||
relay?: IRelay
|
||||
|
|
Loading…
Reference in New Issue