-
Notifications
You must be signed in to change notification settings - Fork 38.7k
Introduce an ArgsManager class encapsulating cs_args, mapArgs and mapMultiArgs #9494
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
ff58b28 to
8a96939
Compare
|
Concept ACK. I think we had discussed doing this when #9243 went in.
…On January 9, 2017 11:02:04 AM EST, "Jorge Timón" ***@***.***> wrote:
Continues #9243 by @TheBlueMatt
Introduce an ArgsManager class encapsulating cs_args, mapArgs and
mapMultiArgs.
To reduce disruption, the used functions are kept as wrapers. The
wrapers can be removed later, see
jtimon@0.13-args-class...jtimon:0.13-args-remove-wrapers
for the less disruptive ones to remove.
You can view, comment on, or merge this pull request online at:
#9494
-- Commit Summary --
* Util: Create ArgsManager class
* Util: Expose ArgsManager argsGlobal
* Util: s/mapMultiArgs.count(/argsGlobal.IsArgSet(/
* Util: Introduce ArgsManager::ArgsAt()
* Util: Put mapMultiArgs inside ArgsManager
-- File Changes --
M src/httprpc.cpp (4)
M src/httpserver.cpp (8)
M src/init.cpp (48)
M src/net.cpp (10)
M src/test/util_tests.cpp (77)
M src/util.cpp (83)
M src/util.h (28)
-- Patch Links --
https://github.com/bitcoin/bitcoin/pull/9494.patch
https://github.com/bitcoin/bitcoin/pull/9494.diff
--
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub:
#9494
|
|
Yes, we discussed it in #9243, but that this seems approximately what was discussed previously is still very useful, thanks. What concerns me more of the current code is the fact that the methods IsArgSet, GetArg, GetBoolArg and ArgsAt aren't const, because they need to |
|
concept ACK 👍 , will review again when able, once-over utACK 8a96939 |
| bool IsArgSet(const std::string& strArg) | ||
| const std::vector<std::string>& ArgsManager::ArgsAt(const std::string& strArg) const | ||
| { | ||
| return mapMultiArgs.at(strArg); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume this should get LOCK(cs_args); too? If so, the method can't be const.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it also cant return a reference, needs to make a copy.
8a96939 to
6086a84
Compare
|
Needed rebase. |
6086a84 to
94fa561
Compare
|
Needed rebase (due to "Refactor: Remove using namespace " PRs). |
|
Concept ACK, seems a move in the right direction. |
|
utACK c67209128a114e3260ab93c3e8a63b1b23663b34 |
|
Concept ACK, will review.
…On March 24, 2017 2:57:16 PM PDT, Pieter Wuille ***@***.***> wrote:
utACK c67209128a114e3260ab93c3e8a63b1b23663b34
--
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub:
#9494 (comment)
|
TheBlueMatt
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Switching mapMultiArgs.count() to argsGlobal.IsArgSet makes a few things incorrect, because the SoftSetArgs stuff doesn't update mapMultiArgs but does update mapArgs. I think the correct solution here is to keep mapMultiArgs and mapArgs consistent (@luke-jr also needed that for the multiwallet pull), though that does mean ArgsAt needs to return a copy and not a reference (which I think is OK - arg usage doesn't need to be fast).
src/httprpc.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: kill the > 0 here?
Maybe a solution could be to use argsGlobal.IsArgsAt().size() > 0 in those cases? Thoughts? |
|
I'd prefer to just fix the issue - I think its super strange that SoftSetArg, etc dont keep mapMultiArgs and mapArgs consistent. |
|
Fixed nits. Also removed a bunch of BOOST_FOREACH for free in the commit that introduces ArgsManager::ArgsAt(). |
4396063 to
5c18d51
Compare
|
Fixed nit. |
|
Needed rebase. |
|
put my review of this code on the wrong PR. #10119 (comment) |
|
utACK f19f5b5 |
|
Sorry, just pushed again changing the history as @TheBlueMatt suggested. |
|
utACK 78da882. Confirmed no diff since previous review, just mapMultiArgs commit history change. |
|
utACK 78da882 |
…pArgs and mapMultiArgs 78da882 Util: Small improvements in gArgs usage (Jorge Timón) 5292245 Util: Put mapMultiArgs inside ArgsManager (Jorge Timón) b3cbd55 scripted-diff: Util: Encapsulate mapMultiArgs behind gArgs (Jorge Timón) f2957ce Util: Create ArgsManager class... (Jorge Timón) Tree-SHA512: 7d58250da440ad0f41745f46ab6021d6ecbb292035cab3d86fb08ce6bd822df604ac31b3ded6fd6914f7cfd12ba531cbc06a76eb500f629627f47ae6ac8350a7
…rgs, mapArgs and mapMultiArgs 78da882 Util: Small improvements in gArgs usage (Jorge Timón) 5292245 Util: Put mapMultiArgs inside ArgsManager (Jorge Timón) b3cbd55 scripted-diff: Util: Encapsulate mapMultiArgs behind gArgs (Jorge Timón) f2957ce Util: Create ArgsManager class... (Jorge Timón) Tree-SHA512: 7d58250da440ad0f41745f46ab6021d6ecbb292035cab3d86fb08ce6bd822df604ac31b3ded6fd6914f7cfd12ba531cbc06a76eb500f629627f47ae6ac8350a7 add ForceRemoveArg and ForceSetMultiArg to ArgsManager class Signed-off-by: Pasta <[email protected]> add static inlines for ForceSetMultiArgs and ForceRemoveArg Signed-off-by: Pasta <[email protected]> both void Signed-off-by: Pasta <[email protected]> use gArgs, dash code Signed-off-by: Pasta <[email protected]> revert a bit Signed-off-by: Pasta <[email protected]> adj Signed-off-by: Pasta <[email protected]> use gArgs Signed-off-by: Pasta <[email protected]> remove '_' Signed-off-by: Pasta <[email protected]>
4709ff8 remove now unused gArgs wrappers (Fuzzbawls) cc40f8d Manual prep for gArg wrapper removal (Fuzzbawls) b3c843c scripted-diff: stop using the gArgs wrappers (Fuzzbawls) 5ce3844 Migrate g_logger fields to gArgs (Fuzzbawls) 72a6f56 Track negated arguments in the argument paser. (Fuzzbawls) 3142e1b Add additional tests for GetBoolArg() (Fuzzbawls) 4aef2f3 Fix constness of ArgsManager methods (Fuzzbawls) 13fd27d Fix indentation after 'Remove redundant calls to gArgs.IsArgSet()' (Fuzzbawls) a4114f3 Util: Remove redundant calls to gArgs.IsArgSet() (Fuzzbawls) 92e7227 Util: Small improvements in gArgs usage (Fuzzbawls) a8b26e7 Util: Put mapMultiArgs inside ArgsManager (Fuzzbawls) d2f2e25 scripted-diff: Util: Encapsulate mapMultiArgs behind gArgs (Fuzzbawls) b2abc59 Util: Create ArgsManager class... (Fuzzbawls) 8c4d9c5 Add a ForceSetArg method for testing (Fuzzbawls) 59d6529 Lock mapArgs/mapMultiArgs access in util (Fuzzbawls) f7f2689 Un-expose mapArgs from util.h (Fuzzbawls) 7894b07 Get rid of mapArgs direct access in ZMQ construction (Matt Corallo) b28789f Introduce (and use) an IsArgSet accessor method (Fuzzbawls) 4d8ecf9 Fix non-const mapMultiArgs[] access after init. (Fuzzbawls) 391388d Remove arguments to ReadConfigFile (Fuzzbawls) Pull request description: This is a cumulation of several upstream backports surrounding the argument parsing code. Included here are the following upstream PRs: - bitcoin#9243 - bitcoin#9494 - bitcoin#10118 - bitcoin#10901 - bitcoin#12713 - bitcoin#10607 I've also refactored the global logging argument parsing to match, as that was an "out-of-order" PR that was previously backported to match our previous state. ACKs for top commit: random-zebra: utACK 4709ff8 furszy: cool encapsulation, utACK 4709ff8 and merging Tree-SHA512: 74c8dc1b2280b726eff44855e9908f3563d4ef6493f296ebfafe240ac6470bc45cbc75baac614ed59dfda9e1377b7da7d47a695dfc05e364cada2468bb99a258
Continues #9243 by @TheBlueMatt
Introduce an ArgsManager class encapsulating cs_args, mapArgs and mapMultiArgs.
To reduce disruption, the used functions are kept as wrapers. The wrapers can be removed later, see jtimon/bitcoin@0.13-args-class...jtimon:0.13-args-remove-wrapers for the less disruptive ones to remove.