-
Notifications
You must be signed in to change notification settings - Fork 12
Description
In the example splice portfolio, TransactionHistoryService provides an API for retrieving past transactions.
Currently this class just stored transactions in an in-memory array, which works as a PoC but isn't great for two reasons:
- All history needs to be fetched again when the user refreshes the page
- Queries are less efficient than they could be without extra work
Additionally, the class currently uses offsets to order transactions. This works when using a single synchronizer, but breaks down in a multi-synchronizer world. Instead, we want to use updateId (for uniqueness) and recordTime (for sorting).
An IndexedDB-based store seems like a good match here. It is widely supported (in particular, browser extensions can also use it). It allows us to have semi-structured data with indices on updateId and recordTime (or alternatively offset if we don't want to solve the multi-synchronizer problem yet).
I recommend using idb to make the API more async-idiomatic.
We will still need to store both parsed and queued (typically we can't parse these yet, but we will once we retrieve older events) transactions. IDBKeyRange.bound/IDBKeyRange.lowerBound/IDBKeyRange.upperBound should make retrieving the right transactions trivial.