xmrdotgift / wallet

A non-custodial Monero wallet that runs in the browser.
https://xmr.gift/wallet
MIT License
8 stars 3 forks source link

Persist wallet cache #9

Open onionltd opened 2 years ago

onionltd commented 2 years ago

When syncing, the wallet is using an in-memory filesystem to store the cache file, which is deleted once the browser tab is reloaded or closed. This leads to constant full syncs which cost time and bandwidth.

monero-javascript supports writing to an arbitrary filesystem as long as it implements the nodejs's fs interface. Public implementations are available for localStorage and IndexedDB.

localStorage can store up to 5MB which probably isn't enough[1] to store the cache, however, IndexedDB allows to allocate more storage and seems like a better fit for this use.

Some of the public implementations are, however, incompatible with monero-javascript due to the latter requiring synchronous API.

[1] https://github.com/monero-project/monero/issues/8366

fossephate commented 2 years ago

Could this work? http://jvilk.com/browserfs/1.4.1/classes/_backend_asyncmirror_.asyncmirror.html