From 060f9e7ac4bbc13c7634641372e89c316d401e4c Mon Sep 17 00:00:00 2001 From: Erik Olsson Date: Thu, 8 Aug 2024 21:43:41 +0200 Subject: [PATCH] handle case where a new miniblock contains a snapshot (#341) --- packages/sdk/src/syncedStream.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/sdk/src/syncedStream.ts b/packages/sdk/src/syncedStream.ts index 091747a97..c1b5f61a9 100644 --- a/packages/sdk/src/syncedStream.ts +++ b/packages/sdk/src/syncedStream.ts @@ -182,9 +182,14 @@ export class SyncedStream extends Stream { .map((e) => e.remoteEvent) .filter(isDefined) + const lastSnapshotMiniblockNum = + miniblock.header.snapshot !== undefined + ? miniblock.header.miniblockNum + : miniblock.header.prevSnapshotMiniblockNum + const cachedSyncedStream = new PersistedSyncedStream({ syncCookie: syncCookie, - lastSnapshotMiniblockNum: miniblock.header.prevSnapshotMiniblockNum, + lastSnapshotMiniblockNum: lastSnapshotMiniblockNum, minipoolEvents: minipoolEvents, lastMiniblockNum: miniblock.header.miniblockNum, })