UNPKG

@waku/utils

Version:
36 lines (35 loc) 1.74 kB
import { type ClusterId, ContentTopic, PubsubTopic, type ShardId } from "@waku/interfaces"; export * from "./type_guards.js"; export * from "./routing_info.js"; export declare const formatPubsubTopic: (clusterId: ClusterId, shard: ShardId) => PubsubTopic; /** * @deprecated will be removed */ export declare const pubsubTopicToSingleShardInfo: (pubsubTopics: PubsubTopic) => { clusterId: ClusterId; shard: ShardId; }; interface ParsedContentTopic { generation: number; application: string; version: string; topicName: string; encoding: string; } /** * Given a string, will throw an error if it is not formatted as a valid content topic for autosharding based on https://rfc.vac.dev/spec/51/ * @param contentTopic String to validate * @returns Object with each content topic field as an attribute */ export declare function ensureValidContentTopic(contentTopic: ContentTopic): ParsedContentTopic; /** * Given a string, determines which autoshard index to use for its pubsub topic. * Based on the algorithm described in the RFC: https://rfc.vac.dev/spec/51//#algorithm */ export declare function contentTopicToShardIndex(contentTopic: ContentTopic, numShardsInCluster: number): number; export declare function contentTopicToPubsubTopic(contentTopic: ContentTopic, clusterId: number, numShardsInCluster: number): string; /** * Given an array of content topics, groups them together by their Pubsub topic as derived using the algorithm for autosharding. * If any of the content topics are not properly formatted, the function will throw an error. */ export declare function contentTopicsByPubsubTopic(contentTopics: ContentTopic[], clusterId: number, networkShards: number): Map<string, Array<string>>;