Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
[WIP] [wallet] dynamic loading/unloading of wallets #10740
Conversation
jnewbery
added some commits
Jun 15, 2017
fanquake
added the
Wallet
label
Jul 5, 2017
jnewbery
added some commits
Jul 3, 2017
| - delete pwallet; | ||
| - } | ||
| - vpwallets.clear(); | ||
| + DeleteWallets(); |
jnewbery
Jul 7, 2017
Member
Yes, DeleteWallets() is a bad name. DeallocWallets() is good, or perhaps DetachWallets()
| @@ -227,40 +227,12 @@ bool CDB::Recover(const std::string& filename, void *callbackDataIn, bool (*reco | ||
| bool CDB::VerifyEnvironment(const std::string& walletFile, const fs::path& dataDir, std::string& errorStr) | ||
| { | ||
| - LogPrintf("Using BerkeleyDB version %s\n", DbEnv::version(0, 0, 0)); |
jonasschnelli
Jul 5, 2017
Member
What's the reasons for keeping this function (that now always returns true)?
jnewbery
Jul 7, 2017
Member
You're right. This (and CWalletDB::VerifyEnvironment()) are now entirely vestigial and are not called. Both can be removed.
| @@ -35,6 +35,8 @@ | ||
| #include <boost/algorithm/string/replace.hpp> | ||
| #include <boost/thread.hpp> | ||
| +/** Protects the vpwallets vector */ | ||
| +CCriticalSection cs_wallets; | ||
| std::vector<CWalletRef> vpwallets; |
jnewbery
Jul 7, 2017
Member
Why? vpwallets is accessed by functions in several of the wallet source files.
jonasschnelli
Jul 9, 2017
Member
I had the idea that walletinit.h/.c is kind of the multiwallet interface (wallet manager). The functions we have there (DeleteWallets(), VerifyWallets(), ShutdownWallets();, etc.) sounded for me after vpwallets belongs there...
IMO, the multiwallet map should ideally not sit within the objects (CWallet) implementation.
|
This overlaps significantly with #10762. Not sure how I should ask for review. Perhaps find out which one people think is the priority? Or I could split the |
| + return obj; | ||
| +} | ||
| + | ||
| +UniValue loadwallet(const JSONRPCRequest& request) |
jnewbery
Jul 7, 2017
Member
On further thought, I think I prefer the names attachwallet and detachwallet. That gives a bit more distinction from the dump/import RPCs and makes a stronger implication that the new .dat file is being loaded and attached as a separate wallet.
|
@jnewbery IMO this one should rebase on the other. |
Makes logical sense. Downside is that the other is a more significant change, so may take longer to get merged. |
|
If this really depends on that work then there's no other way than waiting. The other downside is that the other commits will show up here too. |
jnewbery commentedJul 4, 2017
•
edited
Work in progress. Builds on top of #10767 and #10604. Not yet ready for code review. Currently looking for concept/API feedback.
Adds
loadwalletandunloadwalletRPCs. This allows wallets to be loaded and unloaded dynamically during runtime without having to stop-start the node with new-walletparams.Main motivation for this was the fact that several wallet parameters are actions for individual wallet load/creation, rather than properties of the wallet component. Examples are
-salvagewallet,-rescan,-usehdand-upgradewallet. Continuing with that config/loading model is difficult in a multi-wallet world - how can users run those actions on individual wallets when loading multiple wallets? This PR offers a solution: individual wallets can be loaded at run-time, and RPC parameters can be passed in to carry out the various wallet-loading actions. Note that none of those load actions are yet implemented in this PR, but can easily be added.A lot of the work in this PR was disentangling wallet initialization and destruction. Hopefully the result is that the interface between init.cpp and the wallet component is now cleaner. All wallet component initialization/destruction functions are now in their own walletinit.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. Hopefully this is also useful work towards #7965 and the removal of circular server<->wallet dependencies. That part of this PR (commits "Add walletinit.cpp" through "remove early call to FlushWallets()") can be separated into a different PR if that makes reviewing easier.
Includes functional test.