Skip to content

Commit a55fa6b

Browse files
committed
explanation
1 parent 4e9af0a commit a55fa6b

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

yarn-project/pxe/src/tagging/sync/sync_sender_tagging_indexes.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,16 @@ export async function syncSenderTaggingIndexes(
5050
// hard limit we give a guarantee to a recipient that he doesn't need to look further than WINDOW_LEN ahead of the
5151
// highest finalized index.
5252
//
53-
// This function synchronizes these two values by iteratively querying the node for a window of indexes at a time,
54-
// storing all those indexes as pending, and then checking the status of each pending index to update its
55-
// finalization status accordingly.
53+
// This function synchronizes the finalized and pending indexes by iteratively querying the node for a window of
54+
// indexes at a time, storing all those indexes as pending, and then checking the status of each pending index to
55+
// update its finalization status accordingly. If we stumble upon a window with no indexes, we stop the loop.
56+
//
57+
// Stopping at that point is safe because of the limit described above - there can never be an index that is more
58+
// than WINDOW_LEN from the highest finalized index.
59+
//
60+
// # Note on performance
61+
// Each window advance requires two queries (logs + tx status). For example, syncing indexes 0–500 with a window of
62+
// 100 takes at least 10 round trips (5 windows × 2 queries).
5663

5764
const finalizedIndex = await taggingDataProvider.getLastFinalizedIndex(secret);
5865

0 commit comments

Comments
 (0)