-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(wallet): preserve pouchdb collection documents when bulkDocs fails #1518
Conversation
PouchDbCollectionStore.setAll used to 1. delete all documents 2. insert the new documents This approach has a problem that when step 2. fails, all documents from db are gone and not re-created. For some collections such as transactions or utxo this is not a problem, because it can recover, but for it is a big problem for WalletRepository, because there is no way to recover the wallets if they are lost. This fix updates setAll to perform the following steps: 1. delete *only* the documents that are intended to be deleted 2. upsert all new documents
81811c6
to
0caf2c4
Compare
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice catch!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work @mkazlauskas 🧙
Context
PouchDbCollectionStore.setAll used to
This approach has a problem that when step 2. fails, all documents from db are gone and not re-created. For some collections such as transactions or utxo this is not a problem, because it can recover, but for it is a big problem for WalletRepository, because there is no way to recover the wallets if they are lost.
LW-11760
Proposed Solution
This fix updates setAll to perform the following steps: