-
Notifications
You must be signed in to change notification settings - Fork 38.6k
Chainparams: Use a regular factory for creating chainparams #6907
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
|
This adds news without frees. I really don't think making this non-static is the right thing to do. |
|
Moved the containers from extern back to static. |
src/test/alert_tests.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.
Probably there's a better example of tests that don't have to depend on the chainparam globals (in this case cGlobalSwitchingChainParams) anymore to make sure they test the same as when CBaseChainParams::MAIN is selected.
Note how the const for the params' reference wasn't possible before.
|
Added some commits to replace Container with boost::scoped_pointer. That also reduces the total diff (by not adding a new file), which is nice. |
|
utACK |
|
Nice work @jtimon |
34173db to
f4d308a
Compare
|
Squashed. |
src/chainparams.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 looks dangerous, as it destroys the chainparams object created by the previous caller. Can you either document this, or switch to a solution that doesn't need that (for example, keeping a std::map<string, CChainParams)?
|
@sipa good point. I would prefer to just remove all its uses (now the factory can be used directly instead) than to think much about solving that problem though (maybe there's not so many calls at this point, I will check). |
5d9e172 to
dbaf458
Compare
|
Added a commit to get rid of |
|
test/miner_tests.cpp:62 needs the old function still. |
dbaf458 to
c81fd49
Compare
|
Oops, fixed. |
2e57103 to
fd6893d
Compare
|
Rebased(1) |
|
re-ACK |
fd6893d to
c64d533
Compare
|
@MarcoFalke Thanks for the heads up, build fixed. |
|
Needs rebase due to #7128 |
c64d533 to
d4bb7a8
Compare
|
Rebased(2) [2 since I started counting for this particular PR. But although the commit says may 22, I've been trying to introduce a proper factory since much longer, at the very least since Nov 6, 2014 see #5229. I've been rebasing maintaining it in one way or another since then, but, still, I'll pretend I understand why this is not ready for 0.12 and that #7128 has been merged first. I'll keep rebasing this particular PR until it's finally merged or nacked, but I'm afraid I won't be able to make this kind of promise many more times]. |
src/bitcoin-cli.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.
I don't like this change, it is useful to have the port numbers for both networks in the help output
(and we have the same for -port)
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.
And I don't like special cases for testnet3 (or any other chain), which I usually find with rgrep "test" or rgrep CBaseChainParams::TESTNET.
Maybe we can loop through all the default ports for each supported chain as in
jtimon@28d961f ?
I mean, that would require something like jtimon@042fdb0 first.
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.
As said, we're doing exactly the same for -port. What makes -rpcport different? #7128 unified these.
Looping through all networks would be overkill, there's no good reason to list regtest here, which is hidden (unless --help-debug). I think the current solution is fine.
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.
@laanwj what about jtimon@dd35471 ?
This way you can bitcoind -testnet --help but bitcoind -regtest --help too.
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.
re difference between -port and rpc-port, I'm removing the testnet3 special case from port too, see https://github.com/bitcoin/bitcoin/pull/6907/files#diff-c865a8939105e6350a50af02766291b7R374
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.
rewarding unification, the change in port was also introduced only 5 days ago in #6961
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 way you can bitcoind -testnet --help but bitcoind -regtest --help too.
I don't think that is better than just listing both in the standard help message. Parametrizing the help message on the network, I dunno, that's not something I'd expect as user.
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.
That can be documented, but I'll just restore the old messages and make another local variable for testnet3.
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, 2 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.
Regarding looping and not wanting to show regtest's information, we could easily do that just by leaving regtest out of supportedChains (see jtimon@160d874#diff-64cbe1ad5465e13bc59ee8bb6f3de2e7R20 ). Although that would also leave it out from jtimon@160d874#diff-de33fb0129cd5121c7098035527b26fdR14 and jtimon@28d961f , which is probably not a big deal. The special case for testnet3 can be solved by replacing a "main and testnet" enumaration whether we loop around 2 or 3 elements.
Just a thought. Or we can just leave it as it is, it's just I thought that I had when I was paranoid about jtimon@28d961f maybe being controversial (as a "too altcoinish" commit) and I just remembered.
Of course, that can be done later if it's done.
dd35471 to
d7938c8
Compare
|
Restored the testnet3 special case as requested by @laanwj |
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.
Where is the !?
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.
For some reason we we're using !testnet, which is the same as main and !!main, but the opposite of !!testnet.
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 wanted to have solved it ages ago in jtimon@3d03f15 (#6423) but that commit depended on the cursed PR #6068 (just as cursed as its several predecessors).
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.
In theory it's not defined for main, it's defined for testnet/regtest only;
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.
What that text refers to, is that users aren't currently allowed to -acceptnonstdtxn=true on mainnet, they can only set -acceptnonstdtxn=false in testnet/regtest, which makes the fact that the displayed default is false (when in testnet/regtest the default is actually true) even more stupid.
I wanted to have solved this in jtimon@a4b28c4 but it depends on the previously mentioned commit.
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.
What about default: %u -> default: %u (testnet), default: %u (regtest)?
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 really think we should solve this by allowing -acceptnonstdtxn=true on mainnet. See jtimon@a4b28c4
d7938c8 to
2cffa7f
Compare
|
re-utACK |
|
ping |
2cffa7f to
bd13782
Compare
|
Rebased (3) |
|
re-ACK bd13782 |
bd13782 to
21f4629
Compare
|
Rebase(4) |
c3fdc95 to
670a464
Compare
|
This is way older than "Oct 29, 2015", @laanwj can you please merge it or close it? |
|
I'm not convinced of the need for this. At least to me it doesn't really make the code easier to understand or follow. Do you need this for anything specific? |
|
I've provided many examples of how this could be useful in the past (including the sizetest testchain, sorry, I don’t have the pr number at hand). This also allows to remove effectively-global-variables from chainparams (without moving the factory out) as discussed very long ago with @theuni. Thank you for asking about what you don't understand, even if it's very late. A "no" is always better than continued silence. |
Yes, sorry for that. I'm just very busy. I have trouble keeping up with all the pulls, and I need to prioritize things that fix bugs or address immediate issues to things that are more speculative like refactors. I wish it was different, and we had a paid full-time team on this and it didn't rest for such a large part on my shoulders :( |
Chainparams: fix the factory the bitcoin#6907 way
Rebased by Pieter Wuille. Cleanup by Matt Corallo.
This makes it simpler for people to create new testchains in their own branches by removing the need to create a new static global variable for the new chains.
It also prepares chainparams and chainparamsbase to be cleaned out of globals by moving the globals and related functions (
Params(), SelectParams(), etc) outside, maybe to globals/server.o and globals/common.o respectively.But that would need another PR after this, something @theuni has been wanting to do for some time.
I would prefer to do this first to be able to leave the 2 factories (which don't need to depend on any global) where they are.
Part of #6382