2023-03-21 02:44:35 +01:00
|
|
|
import type { GossipSub } from "@chainsafe/libp2p-gossipsub";
|
2022-12-05 17:00:24 +11:00
|
|
|
|
2023-03-21 02:07:59 +01:00
|
|
|
import type { IDecodedMessage, IDecoder } from "./message.js";
|
|
|
|
|
import type { Callback } from "./protocols.js";
|
|
|
|
|
import type { ISender } from "./sender.js";
|
2022-12-05 17:00:24 +11:00
|
|
|
|
2023-03-21 02:44:35 +01:00
|
|
|
type PubSubTopic = string;
|
|
|
|
|
type ContentTopic = string;
|
2023-03-15 21:47:56 +01:00
|
|
|
|
2023-03-21 02:44:35 +01:00
|
|
|
export type ActiveSubscriptions = Map<PubSubTopic, ContentTopic[]>;
|
2023-03-15 21:47:56 +01:00
|
|
|
|
2023-03-21 02:07:59 +01:00
|
|
|
interface IRelayAPI {
|
2022-12-05 17:07:03 +11:00
|
|
|
addObserver: <T extends IDecodedMessage>(
|
|
|
|
|
decoder: IDecoder<T>,
|
2022-12-05 17:00:24 +11:00
|
|
|
callback: Callback<T>
|
|
|
|
|
) => () => void;
|
|
|
|
|
getMeshPeers: () => string[];
|
2023-03-21 02:44:35 +01:00
|
|
|
getActiveSubscriptions: () => ActiveSubscriptions | undefined;
|
2022-12-05 17:00:24 +11:00
|
|
|
}
|
2023-03-15 21:47:56 +01:00
|
|
|
|
2023-03-21 02:44:35 +01:00
|
|
|
export type IRelay = IRelayAPI & GossipSub & ISender;
|