Includes:
- Introduce an ArgsManager class encapsulating cs_args, mapArgs and mapMultiArgs #9494
I'm happy squashing the indentation commit, leaving it separated or leaving it out of the PR.
Needed rebase.
Needed rebase after #9494 was merged. The indentation is improved for the first commit but the second commit making the indentation complete was not rebased and was removed instead. If it is wanted I am happy to re-write it.
Also, before this wasn't passing the python tests because it needed the change in ArgsManager::GetArgs().
92 | @@ -93,10 +93,8 @@ static bool multiUserAuthorized(std::string strUserPass) 93 | std::string strUser = strUserPass.substr(0, strUserPass.find(":")); 94 | std::string strPass = strUserPass.substr(strUserPass.find(":") + 1); 95 | 96 | - if (gArgs.IsArgSet("-rpcauth")) { 97 | - //Search for multi-user login/pass "rpcauth" from config 98 | - BOOST_FOREACH(std::string strRPCAuth, gArgs.GetArgs("-rpcauth")) 99 | - { 100 | + //Search for multi-user login/pass "rpcauth" from config 101 | + BOOST_FOREACH(std::string strRPCAuth, gArgs.GetArgs("-rpcauth")) {
We generally prefer to remove BOOST while changing lines, no (also, I believe could constify the strRPCAuth, while you're at it)?
Note you can also remove the IsArgSet("-addnode") at the top of ThreadOpenAddedConnections.
Also, would highly prefer you not leave indentation broken everywhere - its easy enough to review with whitespace diff ignored.
Fixed nits, squash pending.
Needed rebase, squashed fixes to @TheBlueMatt 's nits.
Needed rebase after #10502 was merged. Now it's slightly easier to review in the sense that #10118 (review) which was fixed as nit in the PR is now irrelevant.
Extra motivation for review: "C'mon, +16 -37, must be good".
419 | @@ -420,7 +420,9 @@ void ArgsManager::ParseParameters(int argc, const char* const argv[]) 420 | std::vector<std::string> ArgsManager::GetArgs(const std::string& strArg) 421 | { 422 | LOCK(cs_args); 423 | - return mapMultiArgs.at(strArg); 424 | + if (IsArgSet(strArg)) 425 | + return mapMultiArgs.at(strArg); 426 | + return std::vector<std::string>();
Could return {};
utACK b527f8d3b10ee2232a921faf934e690af0e14640
Fixed @ryanofsky 's nit.
utACK a0c00786d488a1022867e7461ff071dd78d2361e. Same as previous, just has the suggested change.
utACK a0c00786d488a1022867e7461ff071dd78d2361e
Concept ACK
If it helps I can do the proper indentation in a commit afterwards, I had it previously but I ditched on rebase out of laziness at some point. Trivial to put it back.
Return empty std::vector<std::string> with ArgsManager::GetArgs if
nothing is set for that string
Needed rebase, added commit for indentation.