Page MenuHomePhabricator

[Cashtab] Cache wallet state in indexedDb

Authored by josephroyking on Apr 13 2021, 17:03.


Group Reviewers
Restricted Project
rABCa96107c13aaa: [Cashtab] Cache wallet state in indexedDb

This is the first step toward caching bcha utxos, slpa utxos, and tx history in local storage.

Currently the largest bottleneck on the server is that the web wallet must poll the server for full utxo history on startup. If state is saved to local storage, then Cashtab can instead only poll for utxo changes, and then only poll changed utxos for SLPA status.

This change does not add utxos or txhistory to state. It only adds what is already stored in state to the cache. Future diffs will add info required for caching, check for state in storage before polling the server, and reduce server calls from all utxos on every startup to only required calls for uncached utxo data.

Test Plan
  1. npm start
  2. Observe in dev console that state is saved to the wallet object.
  3. Confirm in dev console under Application --> IndexedDb that the wallet object has been saved with new state parameter.
  4. Activate a different wallet.
  5. Confirm that your previously active wallet was written to savedWallets in IndexedDb with state parameter.

There are no unit tests for this diff because the app is designed to work whether or not state has been saved. A unit test mocking localForage does not add anything; equivalent to saying "expect true to be true."

Diff Detail

rABC Bitcoin ABC
Lint Passed
No Test Coverage
Build Status
Buildable 15495
Build 30910: Build Diffcashtab-tests
Build 30909: arc lint + arc unit