Danish Arora 3166a5135e
chore!: change all instances of PubSubTopic to PubsubTopic (#1703)
* rename all PubSub patterns

* feat: forbid identifiers with camelcase pubSub (#1709)

---------

Co-authored-by: Arseniy Klempner <adklempner@gmail.com>
2023-11-14 18:52:52 +03:00

23 lines
999 B
TypeScript

import type { GossipSub } from "@chainsafe/libp2p-gossipsub";
import type { PeerIdStr, TopicStr } from "@chainsafe/libp2p-gossipsub/types";
import type { PubsubTopic } from "./misc.js";
import type { IReceiver } from "./receiver.js";
import type { ISender } from "./sender.js";
/**
* Interface representing the Relay API, providing control and information about the GossipSub protocol.
*
* @property gossipSub - The GossipSub instance used for managing pub/sub behavior.
* @property start - Function to start the relay, returning a Promise that resolves when initialization is complete.
* @property getMeshPeers - Function to retrieve the mesh peers for a given topic or all topics if none is specified. Returns an array of peer IDs as strings.
*/
export interface IRelayAPI {
readonly pubsubTopics: Set<PubsubTopic>;
readonly gossipSub: GossipSub;
start: () => Promise<void>;
getMeshPeers: (topic?: TopicStr) => PeerIdStr[];
}
export type IRelay = IRelayAPI & ISender & IReceiver;