Danish Arora 5ce36c8f18
feat!: deprecate named pubsub topics and use static/auto sharding (#2097)
* feat: deprecate named sharding & protocols adhere
simplify network config type, all protocols use pubsub topic internally

* chore: update tests

* tests: rm application info

* chore: use static sharding and auto sharding terminologies

* chore: update docs for network config

* chore: update interfaces

* tests: update tests error message

* chore: remove `ShardingParams` type and fix test
2024-08-13 05:23:20 +05:30

31 lines
891 B
TypeScript

import type { Multiaddr } from "@multiformats/multiaddr";
export * from "./is_defined.js";
export * from "./random_subset.js";
export * from "./group_by.js";
export * from "./to_async_iterator.js";
export * from "./is_size_valid.js";
export * from "./sharding/index.js";
export * from "./push_or_init_map.js";
export * from "./relay_shard_codec.js";
export * from "./delay.js";
export function removeItemFromArray(arr: unknown[], value: unknown): unknown[] {
const index = arr.indexOf(value);
if (index > -1) {
arr.splice(index, 1);
}
return arr;
}
export function getWsMultiaddrFromMultiaddrs(
addresses: Multiaddr[]
): Multiaddr {
const wsMultiaddr = addresses.find(
(addr) => addr.toString().includes("ws") || addr.toString().includes("wss")
);
if (!wsMultiaddr) {
throw new Error("No ws multiaddr found in the given addresses");
}
return wsMultiaddr;
}