
















@@ -67,6 +67,7 @@ export function createTelegramUpdateTracker(options: TelegramUpdateTrackerOption
6767const activeHandledUpdateKeys = new Map<string, boolean>();
6868const pendingUpdateIds = new Set<number>();
6969const failedUpdateIds = new Set<number>();
70+const completedFloorReplayUpdateIds = new Set<number>();
7071let highestAcceptedUpdateId: number | null = initialUpdateId;
7172let highestPersistedAcceptedUpdateId: number | null = persistenceFloorUpdateId;
7273let highestPersistenceRequestedUpdateId: number | null = persistenceFloorUpdateId;
@@ -129,6 +130,11 @@ export function createTelegramUpdateTracker(options: TelegramUpdateTrackerOption
129130highestAcceptedUpdateId = updateId;
130131};
131132133+const isFloorReplayUpdateId = (updateId: number) =>
134+initialUpdateId === null &&
135+persistenceFloorUpdateId !== null &&
136+updateId <= persistenceFloorUpdateId;
137+132138function resolveSafeCompletedUpdateId() {
133139if (highestCompletedUpdateId === null) {
134140return null;
@@ -178,7 +184,12 @@ export function createTelegramUpdateTracker(options: TelegramUpdateTrackerOption
178184const updateKey = buildTelegramUpdateKey(ctx);
179185if (typeof updateId === "number") {
180186if (highestAcceptedUpdateId !== null && updateId <= highestAcceptedUpdateId) {
181-if (!failedUpdateIds.has(updateId)) {
187+const floorReplay = isFloorReplayUpdateId(updateId);
188+if (!floorReplay && !failedUpdateIds.has(updateId)) {
189+skip(`update:${updateId}`);
190+return { accepted: false, reason: "accepted-watermark" };
191+}
192+if (floorReplay && completedFloorReplayUpdateIds.has(updateId)) {
182193skip(`update:${updateId}`);
183194return { accepted: false, reason: "accepted-watermark" };
184195}
@@ -229,6 +240,9 @@ export function createTelegramUpdateTracker(options: TelegramUpdateTrackerOption
229240pendingUpdateIds.delete(update.updateId);
230241if (finish.completed) {
231242failedUpdateIds.delete(update.updateId);
243+if (isFloorReplayUpdateId(update.updateId)) {
244+completedFloorReplayUpdateIds.add(update.updateId);
245+}
232246if (highestCompletedUpdateId === null || update.updateId > highestCompletedUpdateId) {
233247highestCompletedUpdateId = update.updateId;
234248}
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。