/*! * Copyright (c) Microsoft Corporation and contributors. All rights reserved. * Licensed under the MIT License. */ import type { ITelemetryContext } from "@fluidframework/runtime-definitions/internal"; import type { BatchStartInfo } from "./remoteMessageProcessor.js"; /** * Detects duplicate batches that can arise from the "parallel fork" scenario: * Container 1 is serialized, and Containers 2 and 3 are rehydrated from that state. * They both catch up and (re)connect in parallel (at the same time), submitting the same local state, * sharing the same batchId and sequence number. * * For "serial fork" detection scenarios see PendingStateManager. */ export declare class DuplicateBatchDetector { /** * Map from batchId to sequenceNumber */ private readonly seqNumByBatchId; /** * We map from sequenceNumber to batchId to find which ones we can stop tracking as MSN advances */ private readonly batchIdsBySeqNum; /** * Initialize from snapshot data if provided - otherwise initialize empty */ constructor(batchIdsFromSnapshot: [number, string][] | undefined); /** * Records this batch's batchId, and checks if it's a duplicate of a batch we've already seen. * If it's a duplicate, also return the sequence number of the other batch for logging. * * @remarks We also use the minimumSequenceNumber to clear out old batchIds that are no longer at risk for duplicates. */ processInboundBatch(batchStart: BatchStartInfo): { duplicate: true; otherSequenceNumber: number; } | { duplicate: false; }; /** * Batches that started before the MSN are not at risk for a sequenced duplicate to arrive, * since the batch start has been processed by all clients, and local batches are deduped and the forked client would close. */ private clearOldBatchIds; /** * Returns a snapshot of the state of the detector which can be included in a summary * and used to "rehydrate" this class when loading from a snapshot. * * @returns A serializable object representing the state of the detector, or undefined if there is nothing to save. */ getRecentBatchInfoForSummary(telemetryContext?: ITelemetryContext): [number, string][] | undefined; } //# sourceMappingURL=duplicateBatchDetector.d.ts.map