@libp2p/pubsub
Version:
libp2p pubsub base class
27 lines • 1.07 kB
TypeScript
import type { Message, PubSubRPCMessage, PublicKey } from '@libp2p/interface';
/**
* Generate a random sequence number
*/
export declare function randomSeqno(): bigint;
/**
* Generate a message id, based on the `key` and `seqno`
*/
export declare const msgId: (key: PublicKey, seqno: bigint) => Uint8Array;
/**
* Generate a message id, based on message `data`
*/
export declare const noSignMsgId: (data: Uint8Array) => Uint8Array | Promise<Uint8Array>;
/**
* Check if any member of the first set is also a member
* of the second set
*/
export declare const anyMatch: (a: Set<number> | number[], b: Set<number> | number[]) => boolean;
/**
* Make everything an array
*/
export declare const ensureArray: <T>(maybeArray: T | T[]) => T[];
export declare const toMessage: (message: PubSubRPCMessage) => Promise<Message>;
export declare const toRpcMessage: (message: Message) => PubSubRPCMessage;
export declare const bigIntToBytes: (num: bigint) => Uint8Array;
export declare const bigIntFromBytes: (num: Uint8Array) => bigint;
//# sourceMappingURL=utils.d.ts.map