Options
All
  • Public
  • Public/Protected
  • All
Menu

Implements the Waku v2 Relay protocol. Must be passed as a pubsub module to a {Libp2p} instance.

implements

{require('libp2p-interfaces/src/pubsub')}

Hierarchy

  • Gossipsub
    • WakuRelay

Index

Constructors

Properties

decryptionKeys: Map<Uint8Array, { contentTopics?: string[]; method?: DecryptionMethod }>
heartbeat: RelayHeartbeat
observers: {}

observers called when receiving new message. Observers under key "" are always called.

Type declaration

  • [contentTopic: string]: Set<(message: WakuMessage) => void>
pubSubTopic: string

Methods

  • addDecryptionKey(key: string | Uint8Array, options?: { contentTopics?: string[]; method?: DecryptionMethod }): void
  • Register a decryption key to attempt decryption of received messages. This can either be a private key for asymmetric encryption or a symmetric key. WakuRelay will attempt to decrypt messages using both methods.

    Strings must be in hex format.

    Parameters

    • key: string | Uint8Array
    • Optional options: { contentTopics?: string[]; method?: DecryptionMethod }

    Returns void

  • addObserver(callback: (message: WakuMessage) => void, contentTopics?: string[]): void
  • Register an observer of new messages received via waku relay

    Parameters

    • callback: (message: WakuMessage) => void

      called when a new message is received via waku relay

    • contentTopics: string[] = []

      Content Topics for which the callback with be called, all of them if undefined, [] or ["",..] is passed.

    Returns void

  • deleteDecryptionKey(key: string | Uint8Array): void
  • Delete a decryption key that was used to attempt decryption of received messages.

    Strings must be in hex format.

    Parameters

    • key: string | Uint8Array

    Returns void

  • deleteObserver(callback: (message: WakuMessage) => void, contentTopics?: string[]): void
  • Remove an observer of new messages received via waku relay. Useful to ensure the same observer is not registered several time (e.g when loading React components)

    Parameters

    Returns void

  • getPeers(): Set<string>
  • start(): Promise<void>
  • Mounts the gossipsub protocol onto the libp2p node and subscribes to the default topic.

    override

    Returns Promise<void>

  • subscribe(pubSubTopic: string): void
  • Subscribe to a pubsub topic and start emitting Waku messages to observers.

    override

    Parameters

    • pubSubTopic: string

    Returns void

Generated using TypeDoc