Consensus: Refactor: Decouple pow from chainparams#5812
Consensus: Refactor: Decouple pow from chainparams#5812laanwj merged 2 commits intobitcoin:masterfrom
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.
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
|
Fixed include duplication reported by @laanwj |
|
utACK |
There was a problem hiding this comment.
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).