-
Notifications
You must be signed in to change notification settings - Fork 38.7k
scripted-diff: Rename wallet database classes #11851
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
Conversation
|
Concept ACK. The current naming is very confusing. There's even a comment in walletdb.h to say so: This should probably go in just before branching v0.16, since rebasing on top of this will be a pain. Other changes you could consider:
I think your suggested class names are good ('checkpoint' is certainly better than 'transaction'!). I can't currently think of anything better. |
Added commit to fix the overview comment: 51eaec4. I didn't move it into
I'd be inclined to rename I'd be inclined to rename Added 1 commits 003b619 -> 51eaec4 (pr/wren.1 -> pr/wren.2, compare) |
|
Nice! I find the "WalletCheckpoint" name kinda confusing, it is a DB batch/transaction, so I'd kinda prefer we stick with "normal" nomenclature there. I'm really not sure that "BerkeleyCheckpoint" makes all that much sense for CDB, either. I kinda wish we'd split it out into an interface and implementation, though not sure if its required for this PR, but its already essentially a pretty clean interface towards a wallet DB backend. |
Yeah, actually checkpoint is a bad name. I just chose it because I saw a |
|
Can you push your latest branch onto ACK changing Checkpoint to Batch or Commit. Please just not transaction! ACK your suggested filename changes. My preferences would be:
I've reviewed your commit changing the overview comment. I think it could be improved further by removing the 'analogous to x in dbwrapper.h' parts, and perhaps changing the ordering and wording, eg: |
Good point. We use the term "Batch" in the context of LevelDB/CCoin stuff, so I'd vote for that. |
Text from bitcoin#11851 (comment) by John Newbery <john@johnnewbery.com>.
|
Updated 51eaec4 -> 4299018 (pr/wren.2 -> pr/wren.3), switching from checkpoint to batch, dropping the CWallet->Wallet rename (because it isn't really related and makes the change bigger), adding some variable renames for consistency, and adding John's comment. The only thing I didn't do yet is rename files. There might be other suggestions for names, and file renames could also happen in a separate PR. |
|
I'm going to hold off reviewing until we're closer to a major release (since I think this only makes sense going in right before branching). Russ - let me know if you disagree and think we should be reviewing/merging sooner. If this does get merged just before a branch, then I think there's no issue with doing |
|
Sounds good to me. It would also make things slightly easier for me if this were merged after #11687, rather than before. |
|
I'm not sure I'd call BerkeleyBatch so low-level or recommend it be BDB-specific. Its public interface is pretty DB-agnostic - Read/Write/Verify/PeriodicFlush. |
Yeah, that code could be pulled out into WalletBatch or a new key-value store generic class. But I think John's comment is basically right. WalletBatch code should be agnostic to berkeley db details and potentially able to work with another key-value backend, while BerkeleyBatch should contain more berkeley specific stuff. This is mostly true right now, and could be made more true with some refactoring, which I can follow up with. You should talk to John though about whether you prefer this comment or the previous comment, or want to combine them somehow. |
|
Concept ACK |
|
Agree on the naming and using However I agree with this as well:
I tend to agree. I have a local patch set that ports the wallet functions to LevelDB. I don't think the interface should hardcode the database implementation name. If you do want to do this, add a typedef so the non-database-specific code can stay without explicit Berkeley* references. e.g.: (this keeps it contained; after all we don't want to have to do another batch rename every time the database changes) |
|
@laanwj, is there a link to your leveldb patch? I'm surprised there's much code in these classes that's reusable for leveldb. BerkeleyEnvironment and BerkeleyDatabase in particular seem pretty tied to Berkeley, though BerkeleyBatch is more independent. I'm thinking perhaps I should move the independent parts of BerkeleyBatch out into WalletBatch along with this renaming to avoid creating new confusion.
I can clean this up more too, but after #11687 this might not be as much of as problem as you would think. #11687 eliminates most references to the BerkeleyEnvironment, BerkeleyBatch, and BerkeleyDatabase outside of the db files. Anyway, I think I will mark this WIP for now because there are other improvements I can make to go along with the renaming, and I think reviewer time would be better spent on #11687 anyway. |
|
I think I found the leveldb wallet branch, it is https://github.com/laanwj/bitcoin/commits/20170310_experiment_leveldb_wallet and #9951. #5686 is also similar. |
Right - the patch replaces pretty much all the code inside the classes. |
Ah, I see. Your concern was narrower than I thought and can be addressed by a typedef like you suggested. Will fix and have the PR ready again soon. I still might want to merge this after #11687, though since #11687 touches a lot of the same code and this being a scripted-diff is easier to rebase |
|
Concept ACK. Was changing |
|
PSA: Everybody commenting here please stop reviewing this work in progress PR and look at #11687 instead :)
This was unintentional but seemed harmless so I just left it in. I can try to tweak the scripted-diff to prevent it. |
Thanks. Sorry for being unclear at first. |
Text from bitcoin#11851 (comment) by John Newbery <john@johnnewbery.com>.
|
Pieter was here. |
-BEGIN VERIFY SCRIPT-
sed -i 's/\<CWalletDBWrapper\>/BerkeleyDatabase/g' src/wallet/db.h src/wallet/db.cpp
sed -i '/statuses/i/** Backend-agnostic database type. */\nusing WalletDatabase = BerkeleyDatabase\;\n' src/wallet/walletdb.h
ren() { git grep -l "\<$1\>" 'src/*.cpp' 'src/*.h' ':(exclude)*dbwrapper*' test | xargs sed -i "s:\<$1\>:$2:g"; }
ren CDBEnv BerkeleyEnvironment
ren CDB BerkeleyBatch
ren CWalletDBWrapper WalletDatabase
ren CWalletDB WalletBatch
ren dbw database
ren m_dbw m_database
ren walletdb batch
ren pwalletdb batch
ren pwalletdbIn batch_in
ren wallet/batch.h wallet/walletdb.h
ren pwalletdbEncryption encrypted_batch
-END VERIFY SCRIPT-
Signed-off-by: Pasta <pasta@dashboost.org>
Text from bitcoin#11851 (comment) by John Newbery <john@johnnewbery.com>.
Text from bitcoin#11851 (comment) by John Newbery <john@johnnewbery.com>.
9519fc3 Backport latest commit-script-check.sh from upstream (furszy) 3b25450 Add m_ prefix to WalletBatch::m_batch (Russell Yanofsky) 4d0fe84 Update walletdb comment after renaming. (Russell Yanofsky) 5c94ffe scripted-diff: Rename wallet database classes (furszy) Pull request description: Scripted diff to rename "some" wallet classes. Backports bitcoin#11851 Pushing it now because this is one of those annoying text-only rename backports that touch many files that we should try to avoid during the development/review period and only merge right after the release gets packed (aka now). ACKs for top commit: random-zebra: utACK 9519fc3 Fuzzbawls: ACK 9519fc3 Tree-SHA512: 95c9f028c0836e7ddd2100eb8e5a9635d02a011994209e0bda0af98f97e788c1b047378cd95722b8b454a22cd295ff1befc201480d0359abe1c4ebd807858da6
Scripted diff to rename some wallet classes. Motivated by discussion in #11687 (comment)
Berkeley* classes are intended to contain BDB specific code, while Wallet* classes are intended to be more backend-agnostic.
Also renamed associated variables: