Navigation Menu

Skip to content
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

refactor: Some wallet cleanups #19980

Merged
merged 2 commits into from Dec 2, 2020
Merged

Conversation

promag
Copy link
Member

@promag promag commented Sep 19, 2020

No description provided.

@promag promag changed the title 2020 09 wallet cleanups refactor: Some wallet cleanups Sep 19, 2020
@promag promag force-pushed the 2020-09-wallet-cleanups branch 3 times, most recently from 84041df to a66278f Compare September 19, 2020 23:45
{
return *database;
assert(static_cast<bool>(m_database));
Copy link
Member Author

Choose a reason for hiding this comment

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

@ryanofsky made this change in the context of bitcoin-core/gui#95 (comment), where m_database can be null.

Copy link
Contributor

Choose a reason for hiding this comment

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

@ryanofsky made this change in the context of bitcoin-core/gui#95 (comment), where m_database can be null.

Would be interested to see branch

@DrahtBot
Copy link
Contributor

DrahtBot commented Sep 20, 2020

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Conflicts

Reviewers, this pull request conflicts with the following ones:

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

@promag
Copy link
Member Author

promag commented Sep 24, 2020

@achow101 @meshcollider ty

chain.initError(error_string);
return false;
}
if (!wallet_paths.insert(database->Filename()).second) {
Copy link
Member

Choose a reason for hiding this comment

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

Since MakeWalletDatabase will have a duplicate open check, this error will never be hit. Instead the user will get a less useful error about Another instance of bitcoin may be using it.

Copy link
Member Author

Choose a reason for hiding this comment

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

What PR changes it? SQLite?

Copy link
Contributor

Choose a reason for hiding this comment

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

In commit "refactor: Drop wallet path determination from VerifyWallets" (c6a5cd7)

re: #19980 (comment)

What PR changes it? SQLite?

Yes, sqlite doesn't keep a global list of databases. I think best thing would be to drop this commit. Even though current check is awkward and I understand wanting to get rid of it, I think it makes more sense to check for duplicate wallets at wallet level not db level like achow says: to be able to distinguish duplicate loads from locking errors, without the db layer needing to keep its own list of open databases.

Wallet code currently keeps a lists of loaded wallets, a list of wallets being loaded in current thread, a list of wallets being loaded in other threads, a list of wallets being unloaded in other threads. I started changes to combine these into one list in #19619, but dropped the changes to keep that PR more focused. BDB has a list of open databases to deal with shared environments, but sqlite doesn't need this complication.

Copy link
Contributor

@ryanofsky ryanofsky left a comment

Choose a reason for hiding this comment

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

Code review ACK 3fcb7cd. Does need rebase. Also, would suggest dropping VerifyWallets commit c6a5cd7 to keep PR from changing behavior and keep it more focused. PR title could then be changed to something like "wallet refactor: consistently call CWallet::GetDatabase"

chain.initError(error_string);
return false;
}
if (!wallet_paths.insert(database->Filename()).second) {
Copy link
Contributor

Choose a reason for hiding this comment

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

In commit "refactor: Drop wallet path determination from VerifyWallets" (c6a5cd7)

re: #19980 (comment)

What PR changes it? SQLite?

Yes, sqlite doesn't keep a global list of databases. I think best thing would be to drop this commit. Even though current check is awkward and I understand wanting to get rid of it, I think it makes more sense to check for duplicate wallets at wallet level not db level like achow says: to be able to distinguish duplicate loads from locking errors, without the db layer needing to keep its own list of open databases.

Wallet code currently keeps a lists of loaded wallets, a list of wallets being loaded in current thread, a list of wallets being loaded in other threads, a list of wallets being unloaded in other threads. I started changes to combine these into one list in #19619, but dropped the changes to keep that PR more focused. BDB has a list of open databases to deal with shared environments, but sqlite doesn't need this complication.

{
return *database;
assert(static_cast<bool>(m_database));
Copy link
Contributor

Choose a reason for hiding this comment

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

@ryanofsky made this change in the context of bitcoin-core/gui#95 (comment), where m_database can be null.

Would be interested to see branch

Copy link
Contributor

@meshcollider meshcollider left a comment

Choose a reason for hiding this comment

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

utACK 9b74461

Copy link
Contributor

@ryanofsky ryanofsky left a comment

Choose a reason for hiding this comment

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

Code review ACK 9b74461. Changes since last review: rebasing due to conflict, dropping wallet path commit c6a5cd7 as suggested in discussion, making GetDatabase() const in the earlier commit. Giving more descriptive title like
"Consistently use CWallet::GetDatabase" instead of "Some wallet cleanups" might motivate more reviews, but this seems about ready

@achow101
Copy link
Member

achow101 commented Dec 1, 2020

Code Review ACK 9b74461

@fanquake fanquake merged commit 80d4231 into bitcoin:master Dec 2, 2020
@promag promag deleted the 2020-09-wallet-cleanups branch December 2, 2020 00:26
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Dec 2, 2020
9b74461 refactor: Assert before dereference in CWallet::GetDatabase (João Barbosa)
021feb3 refactor: Drop redudant CWallet::GetDBHandle (João Barbosa)

Pull request description:

ACKs for top commit:
  achow101:
    Code Review ACK 9b74461
  meshcollider:
    utACK 9b74461
  ryanofsky:
    Code review ACK 9b74461. Changes since last review: rebasing due to conflict, dropping wallet path commit c6a5cd7 as suggested in discussion, making GetDatabase() const in the earlier commit. Giving more descriptive title like

Tree-SHA512: 68cf3b5e9fe0acb3a5cd081086629989f213f1904cc344e5775767b56759a7d905b1e1c303afbe40f172ff81bf07f3719b59d8f6ec2de3fdd53cd0e2d220fb25
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Feb 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants