HathorNetwork / hathor-wallet-lib

Lib to create wallets using Hathor's full node API.
https://hathor.network/
MIT License
20 stars 13 forks source link

Create savePersistent and saveMemory functions in store #68

Open obiyankenobi opened 4 years ago

obiyankenobi commented 4 years ago

The lib needs to save some that on the storage, but some of it just needs to be in memory. Right now, we save wallet:data in memory, using a specific if in the store setItem implementations (on desktop and mobile) to check that:

if (key === 'wallet:data') {
  // no need to save in disk, just memory
}

Wallet implementations shouldn't need to know these details. We should change the store interface to have two save methods: setItemPersistent and setItemTemporary. The lib will know which one it should call.

msbrogli commented 4 years ago

I completely agree with the suggested refactor, but I couldn't find if (key === 'wallet:data'). As far as I remember, it was used for debugging an issue, but it has never been merged.

obiyankenobi commented 4 years ago

Desktop wallet: https://github.com/HathorNetwork/hathor-wallet/blob/master/src/storage.js#L62

Mobile wallet (about to merge): https://github.com/HathorNetwork/hathor-wallet-mobile/pull/53/files#diff-3bf35cd41da51153dcca3003656f7c67R32