import { GossipSub, GossipSubComponents, GossipsubOpts } from "@chainsafe/libp2p-gossipsub"; import type { PeerIdStr, TopicStr } from "@chainsafe/libp2p-gossipsub/types"; import { Callback, CreateNodeOptions, IAsyncIterator, IDecodedMessage, IDecoder, IEncoder, IMessage, IRelay, type IRoutingInfo, Libp2p, LightPushSDKResult, PubsubTopic } from "@waku/interfaces"; export type Observer = { decoder: IDecoder; callback: Callback; }; export type RelayCreateOptions = CreateNodeOptions & { routingInfos: IRoutingInfo[]; } & Partial; export type ContentTopic = string; type ActiveSubscriptions = Map; type RelayConstructorParams = { libp2p: Libp2p; pubsubTopics: PubsubTopic[]; }; /** * Implements the [Waku v2 Relay protocol](https://rfc.vac.dev/spec/11/). * Throws if libp2p.pubsub does not support Waku Relay */ export declare class Relay implements IRelay { pubsubTopics: Set; private defaultDecoder; static multicodec: string; readonly gossipSub: GossipSub; /** * observers called when receiving new message. * Observers under key `""` are always called. */ private observers; constructor(params: RelayConstructorParams); /** * Mounts the gossipsub protocol onto the libp2p node * and subscribes to all the topics. * * @override * @returns {void} */ start(): Promise; /** * Wait for at least one peer with the given protocol to be connected and in the gossipsub * mesh for all pubsubTopics. */ waitForPeers(): Promise; /** * Send Waku message. */ send(encoder: IEncoder, message: IMessage): Promise; subscribeWithUnsubscribe(decoders: IDecoder | IDecoder[], callback: Callback): () => void; subscribe: (decoders: IDecoder | IDecoder[], callback: Callback) => () => void; private removeObservers; toSubscriptionIterator(decoders: IDecoder | IDecoder[]): Promise>; getActiveSubscriptions(): ActiveSubscriptions; getMeshPeers(topic?: TopicStr): PeerIdStr[]; private subscribeToAllTopics; private processIncomingMessage; /** * Subscribe to a pubsub topic and start emitting Waku messages to observers. * * @override */ private gossipSubSubscribe; private isRelayPubsub; } export declare function wakuGossipSub(init?: Partial): (components: GossipSubComponents) => GossipSub; export {};