interface RelayNode {
    connectionManager: IConnectionManager;
    filter: undefined;
    health: IHealthManager;
    libp2p: Libp2p;
    lightPush: undefined;
    peerId: PeerId;
    protocols: string[];
    relay: IRelay;
    store: undefined;
    dial(peer, protocols?): Promise<Stream>;
    isConnected(): boolean;
    isStarted(): boolean;
    start(): Promise<void>;
    stop(): Promise<void>;
    waitForPeers(protocols?, timeoutMs?): Promise<void>;
}

Hierarchy (view full)

Properties

connectionManager: IConnectionManager
filter: undefined
libp2p: Libp2p
lightPush: undefined
peerId: PeerId

Returns a unique identifier for a node on the network.

Example

console.log(waku.peerId); // 12D3KooWNmk9yXHfHJ4rUduRqD1TCTHkNFMPF9WP2dqWpZDL4aUb
protocols: string[]

Returns a list of supported protocols.

Example

console.log(waku.protocols); // ['/ipfs/id/1.0.0', '/ipfs/ping/1.0.0', '/vac/waku/filter-push/2.0.0-beta1', '/vac/waku/metadata/1.0.0']
relay: IRelay
store: undefined

Methods

  • Dials to the provided peer

    Parameters

    • peer: PeerId | MultiaddrInput

      information to use for dialing

    • Optional protocols: Protocols[]

      array of Waku protocols to be used for dialing. If no provided - will be derived from mounted protocols.

    Returns Promise<Stream>

    Promise that will resolve to a Stream to a dialed peer

    Example

    await waku.dial(remotePeerId, [Protocols.LightPush]);

    waku.isConnected() === true;
  • Returns boolean

    true if the node has working connection and false otherwise

  • Returns boolean

    true if the node was started and false otherwise

  • Starts all services and components related to functionality of Waku node.

    Returns Promise<void>

    Promise that will resolve when started.

    Example

    await waku.start();

    waku.isStarted() === true;
  • Stops all recurring processes and services that are needed for functionality of Waku node.

    Returns Promise<void>

    Promise that resolves when stopped.

    Example

    await waku.stop();

    waku.isStarted === false;
  • Resolves when Waku successfully gains connection to a remote peers that fits provided requirements. Must be used after attempting to connect to nodes, using IWaku.dial or if was bootstrapped by using IPeerExchange or DnsDiscoveryComponents.

    Parameters

    • Optional protocols: Protocols[]

      Protocols that need to be enabled by remote peers

    • Optional timeoutMs: number

      Timeout value in milliseconds after which promise rejects

    Returns Promise<void>

    Promise that resolves if all desired protocols are fulfilled by at least one remote peer, rejects if the timeoutMs is reached

    Throws

    If passing a protocol that is not mounted or Waku node is not started

    Example

    try {
    // let's wait for at least one LightPush node and timeout in 1 second
    await waku.waitForPeers([Protocols.LightPush], 1000);
    } catch(e) {
    waku.isConnected() === false;
    console.error("Failed to connect due to", e);
    }

    waku.isConnected() === true;