Client storage indexdb 280#290
Open
somotochukwu-dev wants to merge 2 commits into
Open
Conversation
|
@somotochukwu-dev Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
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.
Summary
Implements an IndexedDB-based client-side sync layer for historical metrics data, reducing bandwidth consumption and enabling instantaneous startup times by serving cached data from local storage.
Changes
New Files
src/lib/indexeddb.ts— IndexedDB utility module providing CRUD operations for historical price data points. Creates astellarflow-historydatabase with apriceHistoryobject store, indexed by asset pair, timestamp, and a compound index for efficient time-range queries. Includes automatic pruning of records older than 7 days.src/app/hooks/useHistoricalSync.ts— Hook that subscribes to live WebSocket price data and automatically syncs it to IndexedDB. Batches writes in 50-point chunks with a 10-second flush interval to avoid excessive transactions. Periodically prunes stale data.src/app/hooks/useHistoricalData.ts— Hooks for reading historical data from IndexedDB:useHistoricalData— query with time range and limit filters, includes arefresh()callbackuseLatestHistoricalData— fetch the N most recent data points for instant startup renderinguseHistoricalAssetPairs— discover all stored asset pairssrc/app/components/providers/HistoryProvider.tsx— Wires the sync layer into the React component tree.Modified Files
src/types/index.ts— AddedHistoricalDataPointinterface with fieldsassetPair,timestamp,price,decimals,source,confidenceScoresrc/app/layout.tsx— AddedSocketProviderandHistoryProviderto the root provider treeTechnical Details
{assetPair}_{timestamp}), preventing duplicate entries from overlapping delta updates.retentionDaysparameter inpruneDataPoints().Closes #280