[wallet] Clarify wallet initialization / destruction interface#10767
[wallet] Clarify wallet initialization / destruction interface#10767maflcko merged 8 commits intobitcoin:masterfrom
Conversation
src/init.cpp
Outdated
There was a problem hiding this comment.
Nothing replacing this code?
There was a problem hiding this comment.
Correct - I don't believe the early wallet flush is necessary (although I may be wrong). See PR description:
The most important one is that Flush() no longer gets called twice on shutdown. I think this is fine, and all the tests pass, but this probably requires some careful consideration from people who are more familiar with the wallet code.
src/init.cpp
Outdated
There was a problem hiding this comment.
What about moving these #ifdef ENABLE_WALLET to walletinit.cpp?
There was a problem hiding this comment.
Because walletinit.cpp is in libbitcoin_wallet, so is not linked if ENABLE_WALLET isn't defined. #10762 will remove the libbitcoin_server -> libbitcoin_wallet dependencies entirely from init.cpp.
|
Rebase needed :-) |
|
This isn't going in until after 0.15. which includes some wallet changes. I'll rebase after 0.15 has been cut. |
|
@jnewbery Got it! Thanks for the clarification. |
|
Rebased on @ryanofsky's #10976 and reduced scope. This PR now only moves the remaining wallet startup/shutdown functions to There should be no change in behavior from this PR. |
ryanofsky
left a comment
There was a problem hiding this comment.
utACK 3f425ee4263f66ab039c089d189b6cad0abbc23c. Looks like a simple cleanup with no change in behavior. FWIW I have similar functions in #10973, but am using {start, stop, shutdown} instead of {WalletCompleteStartup, FlushWallets, ShutdownWallets}. Links: declarations, definitions
src/wallet/init.h
Outdated
There was a problem hiding this comment.
In commit "[wallet] move wallet flush calls to wallet/init.cpp"
I think you need to use //! prefix on each line of the comment for doxygen to pick it up.
src/init.cpp
Outdated
There was a problem hiding this comment.
In commit "[wallet] move wallet detach calls to wallet/init.cpp"
Maybe go with "close" or "free" instead of "detach". Detach sounds like it could be keeping the wallets open but handing them off.
src/wallet/init.h
Outdated
src/wallet/init.cpp
Outdated
There was a problem hiding this comment.
Offtopic, we could ditch CWalletRef.
src/init.cpp
Outdated
src/wallet/init.h
Outdated
src/wallet/init.h
Outdated
src/wallet/init.h
Outdated
src/wallet/init.h
Outdated
|
Re: naming of unload/close/free/detach wallet function. I want the wallet loading/unloading RPC verbs to be antonyms so it's obvious they're carrying out opposite actions. I started with load/unload, but dropped that to avoid any ambiguity with adding keys and addresses to an already open wallet. attach/detach is bad for the reason Russ mentioned. Is everyone happy with open/close? (I guess the name of the function doesn't need to map exactly to the name of the RPC, but I think it makes sense to do that if we can) |
|
open/close or load/unload is what I would call it |
|
I've addressed the comments and changed names a little. @ryanofsky do you mind taking a look? |
ryanofsky
left a comment
There was a problem hiding this comment.
utACK ca94bf2c39b06f1ed643c24dfcd78ef5af00562a. Note that what you're calling flush, I'm calling stop in #10973, and what you're calling stop, I'm calling shutdown. But I'm not too worried about the names.
#10973 links: declarations, definitions
|
Also just a suggestion, but this might be easier to review if it were just 2 commits, one commit for RPC stuff and one commit for the start/stop/flush stuff, so you could see the related parts together. |
|
Thanks @ryanofsky . Other reviewers/maintainers - I'm happy to rebase/squash as Russ suggests if that makes things easier to review. Please let me know if you want that. |
|
utACK ca94bf2 |
TheBlueMatt
left a comment
There was a problem hiding this comment.
utACK ca94bf2c39b06f1ed643c24dfcd78ef5af00562a. I'm willing to bet this materially reduces the memory usage/compile time of init.cpp due to the wallet.h import removal.
src/init.cpp
Outdated
There was a problem hiding this comment.
Holy fuck yes, kill the imports.
src/init.cpp
Outdated
There was a problem hiding this comment.
Can you add the rationale for rename in the commit message? Why not keep it?
There was a problem hiding this comment.
@jnewbery Or add it to the OP, so it can be seen in the merge commit.
src/wallet/init.h
Outdated
There was a problem hiding this comment.
Comment should say "WalletParameterInteraction"
There was a problem hiding this comment.
added as trivial commit
Rationale: - this init function can now open multiple wallets (hence Wallet->Wallets) - This is named as the antonym to CloseWallets(), which carries out the opposite action.
This function can now verify multiple wallets.
ca94bf2 to
5d2a399
Compare
|
@MarcoFalke - nits addressed. Should be ready for merge if Travis agrees. |
|
re-utACK commit-by-commit 5d2a399 |
…terface 5d2a399 [trivial] fixup comment for VerifyWallets() (John Newbery) 43b0e81 [wallet] Add StartWallets() function to wallet/init.cpp (John Newbery) 290f3c5 [wallet] Add RegisterWalletRPC() function to wallet/init.cpp (John Newbery) 062d631 [wallet] Add CloseWallets() function to wallet/init.cpp (John Newbery) 77fe07c [wallet] Add StopWallets() function to wallet/init.cpp (John Newbery) 2da5eaf [wallet] Add FlushWallets() function to wallet/init.cpp (John Newbery) 1b9cee6 [wallet] Rename WalletVerify() to VerifyWallets() (John Newbery) 9c76ba1 [wallet] Rename InitLoadWallet() to OpenWallets() (John Newbery) Pull request description: Apologies for the mostly code move only PR. This is a pre-req for both #10740 and #10762 All wallet component initialization/destruction functions are now in their own `wallet/init.cpp` translation unit and are no longer static functions on the CWallet class. The bitcoin_server also no longer has any knowledge that there are multiple wallets in vpwallet. There should be no changes in behavior from this PR. Tree-SHA512: 7c260eb094f2fa1a88d803769ba60935810968a7309f731135e4b17623b97f18c03bbcd293c942093d1efce62c6c978f9ff484d54dc9a60bc2fcb5af2d160fcd
…tion interface 5d2a399 [trivial] fixup comment for VerifyWallets() (John Newbery) 43b0e81 [wallet] Add StartWallets() function to wallet/init.cpp (John Newbery) 290f3c5 [wallet] Add RegisterWalletRPC() function to wallet/init.cpp (John Newbery) 062d631 [wallet] Add CloseWallets() function to wallet/init.cpp (John Newbery) 77fe07c [wallet] Add StopWallets() function to wallet/init.cpp (John Newbery) 2da5eaf [wallet] Add FlushWallets() function to wallet/init.cpp (John Newbery) 1b9cee6 [wallet] Rename WalletVerify() to VerifyWallets() (John Newbery) 9c76ba1 [wallet] Rename InitLoadWallet() to OpenWallets() (John Newbery) Pull request description: Apologies for the mostly code move only PR. This is a pre-req for both bitcoin#10740 and bitcoin#10762 All wallet component initialization/destruction functions are now in their own `wallet/init.cpp` translation unit and are no longer static functions on the CWallet class. The bitcoin_server also no longer has any knowledge that there are multiple wallets in vpwallet. There should be no changes in behavior from this PR. Tree-SHA512: 7c260eb094f2fa1a88d803769ba60935810968a7309f731135e4b17623b97f18c03bbcd293c942093d1efce62c6c978f9ff484d54dc9a60bc2fcb5af2d160fcd
…tion interface 5d2a399 [trivial] fixup comment for VerifyWallets() (John Newbery) 43b0e81 [wallet] Add StartWallets() function to wallet/init.cpp (John Newbery) 290f3c5 [wallet] Add RegisterWalletRPC() function to wallet/init.cpp (John Newbery) 062d631 [wallet] Add CloseWallets() function to wallet/init.cpp (John Newbery) 77fe07c [wallet] Add StopWallets() function to wallet/init.cpp (John Newbery) 2da5eaf [wallet] Add FlushWallets() function to wallet/init.cpp (John Newbery) 1b9cee6 [wallet] Rename WalletVerify() to VerifyWallets() (John Newbery) 9c76ba1 [wallet] Rename InitLoadWallet() to OpenWallets() (John Newbery) Pull request description: Apologies for the mostly code move only PR. This is a pre-req for both bitcoin#10740 and bitcoin#10762 All wallet component initialization/destruction functions are now in their own `wallet/init.cpp` translation unit and are no longer static functions on the CWallet class. The bitcoin_server also no longer has any knowledge that there are multiple wallets in vpwallet. There should be no changes in behavior from this PR. Tree-SHA512: 7c260eb094f2fa1a88d803769ba60935810968a7309f731135e4b17623b97f18c03bbcd293c942093d1efce62c6c978f9ff484d54dc9a60bc2fcb5af2d160fcd
Apologies for the mostly code move only PR. This is a pre-req for both #10740 and #10762
All wallet component initialization/destruction functions are now in their own
wallet/init.cpptranslation unit and are no longer static functions on the CWallet class. The bitcoin_server also no longer has any knowledge that there are multiple wallets in vpwallet.There should be no changes in behavior from this PR.