-
Notifications
You must be signed in to change notification settings - Fork 38.6k
Chainparams: Translations: DRY: options and error strings #6235
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
|
Needed rebase. Also replaced GetParamsHelpMessages with AppendParamsHelpMessages, which optionally takes a showDebugHelp boolean. |
|
@theuni this may interact with your code. |
|
Closing for now to reduce noise |
|
Great. MAX_NETWORK_TYPES is removed in the second commit. |
|
Ack (tested). |
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.
Why move away from a switch case construct?
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.
You can't switch on a string...
|
General approach OK. Comments:
Seems like you want find_chain_by_string(), returns id, which can be passed around efficiently as 'network' -- which is consistent with what the rest of the code does now. |
|
@jgarzik since each param has a strNetworkID which is exactly the same as the CBaseChainParams constants introduced, I think a set would be the simplest. Re-introducing an intermediate type would defeat the point of these patches for me, which is to allow me to easily create a new testnet. I've been hacking bitcoind to run a megablocks testnet, for example. But I like the simplicity of the patch's mechanical translation; easy to review. A lookup mechanism on top could work well as a new patch. |
Yes, the string comparison is more expensive, but it's done on init or tests, so I think it's fine.
@jgarzik I'm not sure I understand your suggestion. |
e9c4ee4 to
e52fee4
Compare
|
Rebased and fixed (see #6077 (comment) ). |
src/chainparamsbase.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.
This last line is outdated. That behaviour moved to the separate generate RPC call.
|
Untested ACK |
|
ut ACK |
e52fee4 to
e32640f
Compare
|
Fixed @sipa 's nit. |
|
ut ACK - though this pushes the bounds of my refactor size-o-meter for end-user utility versus source code disturbance ;p |
|
utACK |
|
ping |
|
ut ACK. I'm not concerned about string comparisons on init. With #6382 NACK'd there is less direct utility to this patch, but I like the deduplication of the error handling. (The whole "selecting chainparams" area of the code can be frustrating to read because it has a lot of redundancy like this.) |
src/chainparamsbase.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.
Options help that is only shown with debugHelp should not be translated (see doc/translation_strings_policy.md)
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 didn't know that, thanks. I will correct it.
|
ut ACK |
src/chainparamsbase.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.
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.
Well, I believe this is an initialization error rather than an internal error. But the initialization errors translation in init.o::AppInit2() seems inconsistent (some times they are translated, some times they aren't).
@laanwj can you help us here?
…ants (suggested by Wladimir)
Also remove SelectBaseParamsFromCommandLine and SelectParamsFromCommandLine
e32640f to
55a8975
Compare
|
Updated without translating errors or messages that are only shown when debugHelp is true (solved @laanwj and @MarcoFalke 's nits). |
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 don't get it, why such stuff is alway reintroduced or even used at all:
Should be: catch (const std::exception& e)
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.
My fault. I would have changed it if someone had nit it on time.
Misc upstream PRs Cherry-picked from the following upstream PRs: - bitcoin/bitcoin#6077 - Second commit only (first was already applied to 0.11.X and then reverted) - bitcoin/bitcoin#6284 - bitcoin/bitcoin#6489 - bitcoin/bitcoin#6462 - bitcoin/bitcoin#6647 - bitcoin/bitcoin#6235 - bitcoin/bitcoin#6905 - bitcoin/bitcoin#6780 - Excluding second commit (QT) and third commit (requires bitcoin/bitcoin#6993) - bitcoin/bitcoin#6961 - Excluding QT parts, and a small `src/policy/policy.cpp` change which depends on a bunch of other PRs, which we'll have to remember to come back to. - bitcoin/bitcoin#7044 - bitcoin/bitcoin#8856 - bitcoin/bitcoin#9002 Part of #2074 and #2132.
Misc upstream PRs Cherry-picked from the following upstream PRs: - bitcoin/bitcoin#6077 - Second commit only (first was already applied to 0.11.X and then reverted) - bitcoin/bitcoin#6284 - bitcoin/bitcoin#6489 - bitcoin/bitcoin#6235 - bitcoin/bitcoin#6905 - bitcoin/bitcoin#6780 - Excluding second commit (QT) and third commit (requires bitcoin/bitcoin#6993) - bitcoin/bitcoin#6961 - Excluding QT parts, and a small `src/policy/policy.cpp` change which depends on a bunch of other PRs, which we'll have to remember to come back to. - bitcoin/bitcoin#7044 - bitcoin/bitcoin#8856 - bitcoin/bitcoin#9002 Part of #2074 and #2132.
…cture d1244f3 Fix UB in CChainParams unique_ptr subclasses destructor. (furszy) cf20f43 Chainparams: Get rid of CChainParams& Params(std::string) (Jorge Timón) eeea862 Chainparams: Use a regular factory for creating chainparams (Jorge Timón) f9d585a More zerocoin unused functions and classes cleanup. (furszy) 029ce7b pivx-cli align -rpcport help message to init.cpp help message. (furszy) 3431977 Chainparams: Translations: DRY: options and error strings Also remove SelectBaseParamsFromCommandLine and SelectParamsFromCommandLin (Jorge Timón) ce7a792 Removed unused AreBaseParamsConfigured() (furszy) 508fec1 Chainparams: Replace CBaseChainParams::Network enum with string constants (furszy) 2a1f16c Chainparams: CTestNetParams and CRegTestParams extend directly from CChainParams (furszy) 0ed1a48 Refactor `Params().NetworkID() == CBaseChainParams::TESTNET` for IsTestnet() direct call. (furszy) Pull request description: Made several updates to the base chain params structure and further cleanups over the zerocoin code: * Replaced `CBaseChainParams::Network` enum with string constants and unified better the network selection error + network help message (adaptation of dashpay#6235). * Removed unused NetworkID field from chain params (dashpay#5598). * Improved the network params creation using a proper factory (adaptation of bitcoin#8855). * Cleaned almost all the zerocoin related functions inside `zerocoin.h/cpp` and `zpivchain.h/cpp`. ACKs for top commit: random-zebra: ACK d1244f3 Fuzzbawls: ACK d1244f3 Tree-SHA512: c7ecb34045f9e14dc60130d3f7142c2f32c4c16f5678e871036db0b513ec3c416762a2464ff0d50383a50d345ea90f2c5958284657479c2becaaf9bf3936fcd3
Make some strings translatable when they weren't.
Don't duplicate error or help translation strings related to chainparams.