mirror of
https://github.com/logos-messaging/logos-messaging-js.git
synced 2026-01-13 05:23:13 +00:00
* `ProtocolCreateOptions` now has `pubSubTopic` as `pubSubTopic[]` * chore: update encoder & decoder to support `PubSubTopic` * feat(protocols): allow multiple `PubSubTopic[]` * feat(relay): allow multiple `PubSubTopic[]` * chore(tests): update for new API * chore: minor fixes * chore: make store more robust * fix(relay): correctly set types * chore(address comments): update terminology around configured pubsub topics * chore(address comments): minor refactoring * chore(relay): split `subscribe` into smaller functions for readability & modularity * chore(address comments): refactor `waitForGossipSubPeerInMesh` * chore(store): only allow to query one `pubSubTopic` * fix: `store` bug * feat(tests): add some basic tests * sharding utils * address comments * feat(relay): re-add API for `getMeshPeers` * update error message Co-authored-by: fryorcraken <110212804+fryorcraken@users.noreply.github.com> * refactor for new API * feat: simplify handling of observers (#1614) * refactor: simplify handling of observers * refactor: Remove redundant PubSubTopic from Observer * use `??` instead of `||` * update `pubsubTopic` to `pubSubTopic` * update `interval` typo * change occurence of `pubsubTopic` to `pubSubTopic` * relay: rm `getAllMeshPeers` and make `pubSubTopics` public * relay: use `push_or_init_map` and move to `utils` * fix: update API for tests * fix: relay waitForRemotePeer --------- Co-authored-by: fryorcraken <110212804+fryorcraken@users.noreply.github.com>
23 lines
989 B
TypeScript
23 lines
989 B
TypeScript
import type { GossipSub } from "@chainsafe/libp2p-gossipsub";
|
|
import type { PeerIdStr, TopicStr } from "@chainsafe/libp2p-gossipsub/types";
|
|
|
|
import { PubSubTopic } from "./misc.js";
|
|
import { 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;
|