import type { RawCoID, SessionID } from "./exports.js"; export type KnownStateSessions = { [sessionID: SessionID]: number; }; export type CoValueFrontier = KnownStateSessions; export type CoValueKnownState = { id: RawCoID; header: boolean; sessions: KnownStateSessions; }; /** * Returns an empty known state for a CoValue, with no header and empty sessions. */ export declare function emptyKnownState(id: RawCoID): CoValueKnownState; /** * Picks the knownState properties from the input object */ export declare function knownStateFrom(input: CoValueKnownState): { id: `co_z${string}`; header: boolean; sessions: KnownStateSessions; }; /** * Mutate the target known state by combining the sessions from the source. * * The function assigns the sessions to the target only when the value in the source is greater. */ export declare function combineKnownStates(target: CoValueKnownState, source: CoValueKnownState): CoValueKnownState; /** * Mutate the target sessions counter by combining the entries from the source. * * The function assigns the sessions to the target only when the value in the source is greater. */ export declare function combineKnownStateSessions(target: KnownStateSessions, source: KnownStateSessions): KnownStateSessions; /** * Set the session counter for a sessionId in the known state. */ export declare function setSessionCounter(knownState: KnownStateSessions, sessionId: SessionID, value: number): void; /** * Update the session counter for a sessionId in the known state. * * The function assigns the value to the target only when the value in the knownState is less than the provided value. */ export declare function updateSessionCounter(knownState: KnownStateSessions, sessionId: SessionID, value: number): void; /** * Efficient cloning of a known state. */ export declare function cloneKnownState(knownState: CoValueKnownState): { id: `co_z${string}`; header: boolean; sessions: { [sessionID: `sealer_z${string}/signer_z${string}_session_z${string}`]: number; [sessionID: `${import("./exports.js").RawAccountID}_session_z${string}`]: number; [sessionID: `sealer_z${string}/signer_z${string}_session_d${string}$`]: number; [sessionID: `${import("./exports.js").RawAccountID}_session_d${string}$`]: number; }; }; /** * Checks if all the local sessions have the same counters as in remote. */ export declare function areCurrentSessionsInSyncWith(current: Record, target: Record): boolean; /** * Checks if all the local sessions have the same counters as in remote. */ export declare function isKnownStateSubsetOf(current: Record, target: Record): boolean; /** * Check if the peer already has all the content from storage. * Returns true if the peer has at least as many transactions as storage for all sessions. */ export declare function peerHasAllContent(storageKnownState: CoValueKnownState, peerKnownState: CoValueKnownState | undefined): boolean; /** * Returns the record with the sessions that need to be sent to the target */ export declare function getKnownStateToSend(current: Record, target: Record): Record; //# sourceMappingURL=knownState.d.ts.map