This pull request is a minimal step in the direction of merging #2124.
The idea is to merge things incrementally rather than all at once.
Automatic sanity-testing: FAILED BUILD/TEST, see http://jenkins.bluematt.me/pull-tester/74c341604961ea9611a6c024c0bdecb573f2361a for binaries and test log.
This could happen for one of several reasons:
If you believe this to be in error, please ping BlueMatt on freenode or TheBlueMatt here.
Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/f48ace32517880418420f45e51b9a97caaa33ce8 for binaries and test log. This is an automated test script which runs test cases on each commit every time is updated. It, however, dies sometimes and fails to test properly, if you are waiting on a test, please check timestamps and if the test.log is moving at http://jenkins.bluematt.me/pull-tester/current/ and contact BlueMatt on freenode if something looks broken.
76 | + { 77 | + strErrors << _("Wallet name may only contain letters, numbers, and underscores."); 78 | + return false; 79 | + } 80 | + 81 | + ENTER_CRITICAL_SECTION(cs_WalletManager);
I think you can better abstract the part between the ENTER_CRITICAL_SECTION and the LEAVE_CRITICAL_SECTION into a separate function that has a LOCK(cs_WalletManager) at the start. This also means you don't need to explicitly leave the section prematurely in case of errors.
Yes, I realized this after I manually parsed the macros in sync.h. But this code is just copy/pasted from the original multiwallet pull request. I'll change it. Thanks for pointing it out.
This pull request has been refactored and reworked a little to improve error messaging.
If you add a dependency on a boost library, please add it to the gitian descriptors too (though it seems overkill to me ofr this purpose).
19 | + 20 | +vector<string> GetFilesAtPath(const boost::filesystem::path& _path, unsigned int flags) 21 | +{ 22 | + vector<string> vstrFiles; 23 | + if (!boost::filesystem::exists(_path)) 24 | + throw runtime_error("Path does not exist.");
A runtime error for this sounds very severe.
It's not that severe if we allow wallets to be stored at arbitrary locations on the file system as in multiwallet-qt. It would be quite severe if _path happened to be the datadir :)
41 | + if (((flags & file_option_flags::REGULAR_FILES) && boost::filesystem::is_regular_file(pFile)) || 42 | + ((flags & file_option_flags::DIRECTORIES) && boost::filesystem::is_directory(pFile))) 43 | +#if defined (BOOST_FILESYSTEM_VERSION) && BOOST_FILESYSTEM_VERSION == 3 44 | + vstrFiles.push_back(pFile.filename().string()); 45 | +#else 46 | + vstrFiles.push_back(pFile.filename());
Indentation problem.
Also, should probably be BOOST_FILESYSTEM_VERSION >= 3. I hope they don't decide to break this again in version 4.
16 | + */ 17 | +typedef std::map<std::string, boost::shared_ptr<CWallet> > wallet_map; 18 | +class CWalletManager 19 | +{ 20 | +protected: 21 | + static const boost::regex WALLET_NAME_REGEX;
Do these need to be exposed?
No, they don't. I'll move them into cpp file when I get a chance.
Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/19f569cdd364592d91453fd246b11e44cef3940e for binaries and test log. This test script verifies pulls every time they are updated. It, however, dies sometimes and fails to test properly. If you are waiting on a test, please check timestamps to verify that the test.log is moving at http://jenkins.bluematt.me/pull-tester/current/ Contact BlueMatt on freenode if something looks broken.
Not sure if this is the appropriate place for this comment, but one feature request I wanted to recommend was to allow for the dynamic creation of wallets via RPC. That way you could add new ones without having to restart the daemon. I think people writing wallet interfaces might find that handy.
Also, this is great work, happy that you're tackling this hard problem. Thanks!
Needs rebase and response to code review comments.