Skip to content

Conversation

@furszy
Copy link

@furszy furszy commented Jan 9, 2021

Back ported bitcoin#9951 + cleaned all of the zerocoin related, not used, methods inside the walletdb class.

Built on top of #2082.

@furszy furszy self-assigned this Jan 9, 2021
@random-zebra random-zebra added this to the 5.1.0 milestone Jan 17, 2021
@random-zebra
Copy link

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.
@furszy furszy force-pushed the 2020_wallet_db_wrapper branch from 3efae28 to 57681d3 Compare January 18, 2021 14:05
@furszy
Copy link
Author

furszy commented Jan 18, 2021

Rebased on top of master. Ready for review.

random-zebra
random-zebra previously approved these changes Jan 20, 2021
Copy link

@random-zebra random-zebra left a 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;

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;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: nullptr

@furszy
Copy link
Author

furszy commented Jan 20, 2021

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).

Yes, absolutely. Was planning to do it on another PR but can tackle it here as well.

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.

Yep, had the same thoughts but it was too much to wrap it here as well.

@furszy
Copy link
Author

furszy commented Jan 21, 2021

PR updated, decoupled the custom backup wallet path and the historical backup code block from the static BackupWallet into their own functions.

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.

@furszy furszy force-pushed the 2020_wallet_db_wrapper branch from dc4c426 to 745e6fc Compare January 22, 2021 01:25
@furszy
Copy link
Author

furszy commented Jan 22, 2021

Updated per @random-zebra's feedback.

random-zebra
random-zebra previously approved these changes Jan 22, 2021
Copy link

@random-zebra random-zebra left a 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.

Copy link
Collaborator

@Fuzzbawls Fuzzbawls left a 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

Copy link

@random-zebra random-zebra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

re-utACK e5fd215

@furszy furszy requested a review from Fuzzbawls January 25, 2021 02:10
Copy link
Collaborator

@Fuzzbawls Fuzzbawls left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK e5fd215

@random-zebra random-zebra merged commit 8ac7333 into PIVX-Project:master Jan 25, 2021
@furszy furszy deleted the 2020_wallet_db_wrapper branch November 29, 2022 14:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants