Page MenuHomePhabricator

[Cashtab] Cache wallet state in indexedDb
ClosedPublic

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

Details

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

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

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable