Implements the Waku v2 Store protocol.

The Waku Store protocol can be used to retrieved historical messages.

Hierarchy

  • WakuStore

Constructors

Properties

libp2p: Libp2p
pubSubTopic: string

Methods

  • Returns known peers from the address book (libp2p.peerStore) that support store protocol. Waku may or may not be currently connected to these peers.

    Returns Promise<Peer[]>

  • Do a query to a Waku Store to retrieve historical/missed messages.

    The callback function takes a Promise<WakuMessage> in input, useful if messages needs to be decrypted and performance matters.

    The order of the messages passed to the callback is as follows:

    • within a page, messages are expected to be ordered from oldest to most recent
    • pages direction depends on pageDirection

    Do note that the resolution of the Promise<WakuMessage | undefined may break the order as it may rely on the browser decryption API, which in turn, may have a different speed depending on the type of decryption.

    Throws

    If not able to reach a Waku Store peer to query, or if an error is encountered when processing the reply, or if two decoders with the same content topic are passed.

    Type Parameters

    Type Parameters

    Parameters

    • decoders: Decoder<T>[]
    • callback: ((message: Promise<undefined | T>) => boolean | void | Promise<boolean | void>)
        • (message: Promise<undefined | T>): boolean | void | Promise<boolean | void>
        • Parameters

          • message: Promise<undefined | T>

          Returns boolean | void | Promise<boolean | void>

    • Optional options: QueryOptions

    Returns Promise<void>

  • Do a query to a Waku Store to retrieve historical/missed messages.

    This is a generator, useful if you want most control on how messages are processed.

    The order of the messages returned by the remote Waku node SHOULD BE as follows:

    • within a page, messages SHOULD be ordered from oldest to most recent
    • pages direction depends on pageDirection

    However, there is no way to guarantee the behavior of the remote node.

    Throws

    If not able to reach a Waku Store peer to query, or if an error is encountered when processing the reply, or if two decoders with the same content topic are passed.

    Type Parameters

    Type Parameters

    Parameters

    Returns AsyncGenerator<Promise<undefined | T>[], any, unknown>

  • Do a query to a Waku Store to retrieve historical/missed messages.

    The callback function takes a WakuMessage in input, messages are processed in order:

    • oldest to latest if options.pageDirection == FORWARD
    • latest to oldest if options.pageDirection == BACKWARD

    The ordering may affect performance. The ordering depends on the behavior of the remote store node. If strong ordering is needed, you may need to handle this at application level and set your own timestamps too (the WakuMessage timestamps are not certified).

    Throws

    If not able to reach a Waku Store peer to query, or if an error is encountered when processing the reply, or if two decoders with the same content topic are passed.

    Type Parameters

    Type Parameters

    Parameters

    • decoders: Decoder<T>[]
    • callback: ((message: T) => boolean | void | Promise<boolean | void>)
        • (message: T): boolean | void | Promise<boolean | void>
        • Parameters

          • message: T

          Returns boolean | void | Promise<boolean | void>

    • Optional options: QueryOptions

    Returns Promise<void>

Generated using TypeDoc