-
Notifications
You must be signed in to change notification settings - Fork 38.7k
Consensus: Refactor: Decouple pow from chainparams #5812
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
|
Looks good, but I still don't see why fSkipProofOfWorkCheck is moved into Consensus::Params. I've been carrying the 2nd patch in one of my refactor trees (without the change to Consensus::Params though, of course). So ACK that part for sure. |
|
As discussed on IRC it is used by CUnitTestParams (which switches this param on and off during tests). |
|
After an IRC discussion, I drop my objection to fSkipProofOfWorkCheck in Params. It's odd, but reasonable. |
src/chainparams.h
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 guess we can get rid of these later, by having callers use Params().GetConsensus().GetX(), rather than Params().GetX(). It's fine for now though, assuming it minimizes diffs.
|
utACK |
|
Well, the plan is actually to have the methods that require consensus params take the struct as a parameter, getting called After that is done with enough functions, all these methods can be removed from CChainParams, like in jtimon@bfda15f |
|
@jtimon Even better; but let's do that later. |
|
Looks good to me, but should be combined with simple POW unit tests to exercise/demonstrate the code.
|
|
ut ACK |
|
Needed rebase. @gavinandresen yes, it would be nice to have more tests for pow, incidentally I just found out that someone already started that by separating CalculateNextWorkRequired from GetNextWorkRequired and testing it (I would have preferred that GetNextWorkRequired was tested directly but better is better). |
|
Rebased after #5883 has been merged to make travis happy. |
|
Needed rebase. |
|
ACK. |
|
Oops, good call. First commit edited with @gavinandresen 's suggestion to correct the documentation. |
src/main.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's a duplicate include
|
Fixed include duplication reported by @laanwj |
|
utACK |
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.
Kudos for passing these parameters explicitly instead of referring to global Params(), breaking the dependency on a global parameter setting will make e.g. testing easier.
d698ef6 Consensus: Refactor: Decouple pow.o from chainparams.o (Jorge Timón) bd00611 Consensus: Refactor: Introduce Consensus::Params class (Jorge Timón)
Introduce a Consensus::Params struct with only consensus specific params. This will be useful for more consensus refactors (see https://github.com/jtimon/bitcoin/commits/consensus_tip).
Then use it in proof of work related methods (which are part of the consensus).