-
Notifications
You must be signed in to change notification settings - Fork 38.7k
Use non-throwing type-safe ChainType where possible #14309
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
|
Concept ACK Nice! |
Reviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
fa827e5 to
fa267ba
Compare
3e75144 to
471c5de
Compare
fa80025 to
fadec8b
Compare
a892601 to
fab0c08
Compare
-BEGIN VERIFY SCRIPT- sed -i --regexp-extended -e 's/(Create(Base)?ChainParams)\(C(Base)?ChainParams::/\1(ChainType::/g' $(git grep -l --extended-regexp 'Create(Base)?ChainParams') sed -i --regexp-extended -e 's/((S|s)elect(Base)?Params)\(C(Base)?ChainParams::/\1(ChainType::/g' $(git grep -l --extended-regexp 'elect(Base)?Params') -END VERIFY SCRIPT-
fab0c08 to
23972de
Compare
fa5cf90 to
fa83f32
Compare
|
What about adding the See #13815 for |
|
|
why not a macro or a simple const string in chainbaseparams.h ? The errors thrown are only thrown during initialization and some of them would disappear with #8994 I'm not sure this adds much value. |
fa83f32 to
8c0eabf
Compare
|
Closing for now, but I think in the longer term we should get rid of exceptions (especially during initialization, where we currently use a string to explicitly pass up errors). |
Currently we use string constants to select different chain rules (e.g "main" or "test"). The obvious downsides are that any function that accepts such a string needs to check if it is one of the known ones and return a runtime error when not found.
This check can be done at compile time by using a
switchstatement on anenum class.To not refactor all the existing code, this first introduces the type-safe
enum class ChainTypeand then runs a scripted diff on all instances where we can benefit from the new class. I intend to remove the throwing and now deprecated methods that pass around the string in a future patch.