-
Notifications
You must be signed in to change notification settings - Fork 725
[Backport] Wallet database handling abstractions/simplifications #2126
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
[Backport] Wallet database handling abstractions/simplifications #2126
Conversation
|
Can be rebased (#2082 merged) |
Abstract database handle from explicit strFilename into CWalletDBWrapper. Backport and adaptation from btc@71afe3c0995592ff17968816a833a8ed3ce05bf2
Instead, CWalletDB() with a dummy handle will just give you a no-op database in which writes always succeeds and reads always fail. CDB already had functionality for this, so just use that.
CWalletDB now contains a CDB instead of inheriting from it. This makes it easier to replace the internal transaction with a different database, without leaking through internals.
This is only for use in the low-level functions, and CDB is already a friend class.
3efae28 to
57681d3
Compare
|
Rebased on top of master. Ready for review. |
random-zebra
left a comment
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.
Looking good. Just few nits.
The CWalletDBWrapper::Backup function, introduced here, is currently never used.
We should refactor BackupWallet (which duplicates most of the code), moving it to CWallet, and making it just a wrapper around this new CWalletDBWrapper::Backup (with proper handling of the custom path).
In the future, we should probably also better encapsulate the methods that deal with the DB, inside CWallet, to avoid using GetDBHandle in so many places (e.g., the RPC, the qt options, or the spkm) which shouldn't have knowledge of lower level db.
| pwalletdbEncryption = new CWalletDB(*dbw); | ||
| if (!pwalletdbEncryption->TxnBegin()) { | ||
| delete pwalletdbEncryption; | ||
| pwalletdbEncryption = NULL; |
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.
nit: nullptr
| } | ||
|
|
||
| delete pwalletdbEncryption; | ||
| pwalletdbEncryption = NULL; |
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.
nit: nullptr
Yes, absolutely. Was planning to do it on another PR but can tackle it here as well.
Yep, had the same thoughts but it was too much to wrap it here as well. |
|
PR updated, decoupled the custom backup wallet path and the historical backup code block from the static This is a previous step before be able to combine and generalize the two backup functions that we currently have into a single one. Will work on it in another PR as the historical backups code is tangled with the GUI notification. Plus.. really needs a focused review. |
dc4c426 to
745e6fc
Compare
|
Updated per @random-zebra's feedback. |
random-zebra
left a comment
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.
utACK 745e6fccbfeb1c2d1e544941366c7f2b73d14ea1
Would be good to add a test for the backupwallet RPC.
We can add it in the follow-up PR that will refactor BackWallet using CWalletDBWrapper::Backup.
Fuzzbawls
left a comment
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.
Overall good, but introduced a compatibility issue with our current minimum supported version of Boost
745e6fc to
e5fd215
Compare
random-zebra
left a comment
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.
re-utACK e5fd215
Fuzzbawls
left a comment
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.
utACK e5fd215
Back ported bitcoin#9951 + cleaned all of the zerocoin related, not used, methods inside the walletdb class.
Built on top of #2082.