chore: move epoch and current slot tracking to web worker#347
Open
asuzuki-jumptrading wants to merge 2 commits into
Open
chore: move epoch and current slot tracking to web worker#347asuzuki-jumptrading wants to merge 2 commits into
asuzuki-jumptrading wants to merge 2 commits into
Conversation
asuzuki-jumptrading
commented
Jun 3, 2026
Collaborator
- This is to prepare to move the skipped cluster slots to the web worker
There was a problem hiding this comment.
Pull request overview
Moves epoch detection (currentEpoch / nextEpoch) and currentSlot progression logic out of the main thread Jotai atoms layer and into the WebSocket web worker, in preparation for moving additional slot-related processing (e.g., skipped cluster slots) into the worker.
Changes:
- Replaced main-thread epoch derivation / caching with worker-side
epochCachethat computes and publishescurrentSlot+{currentEpoch,nextEpoch}to the UI. - Extended worker→UI message protocol to include
currentSlotandepochDatamessages. - Updated main-thread WS data plumbing to consume the new worker messages and stop processing
epoch:newevents inuseUpdateAtoms.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/atoms.ts | Removes epoch list/derivation logic; makes epochAtom/nextEpochAtom worker-fed primitives; stops advancing currentSlot from setSlotStatusAtom. |
| src/api/worker/types.ts | Adds FromWorkerMessage variants for currentSlot and epochData (carrying Epoch types). |
| src/api/worker/messageHandler.ts | Adds epochCache and feeds it with epoch:new and qualifying slot updates; posts new worker messages. |
| src/api/worker/cache/epochCache.ts | New worker-side cache responsible for tracking currentSlot and resolving current/next epoch. |
| src/api/useSetAtomWsData.ts | Consumes currentSlot/epochData worker messages to set atoms; stops handling epoch topic in main-thread update switch. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
f10ed12 to
86a7974
Compare
| set(_currentSlotAtom, (prev) => Math.max(slot, prev ?? 0)); | ||
| }, | ||
| ); | ||
| return atom( |
Collaborator
Author
There was a problem hiding this comment.
This PR corrects the nextLeaderSlot update to only get called with the new max current slot (instead of for all set current slot calls).
86a7974 to
e36b12d
Compare
e36b12d to
49c0d35
Compare
| historyWindowMs: overviewRenderWindowMs + overviewHistoryBufferMs, | ||
| }; | ||
|
|
||
| function isEntry< |
Collaborator
Author
There was a problem hiding this comment.
moved to types.ts
amliu-jumptrading
previously approved these changes
Jun 5, 2026
amliu-jumptrading
approved these changes
Jun 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.