-
Notifications
You must be signed in to change notification settings - Fork 38.7k
Refactor proof of work related functions out of main #3839
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
|
Perhaps these should be moved to a chain params class? |
src/pow.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.
@luke-jr do you mean move these to chainparams?
|
Right, a function on CChainParams |
|
Yeah, I mean move the entire functions. |
|
@luke-jr my understanding (based on what @laanwj and @sipa have told me) is that CChainParams should only contain constants, so I think only the functions should remain out of chainparams like @Drak suggested. |
|
Right, CChainParams should only contain constants. And we don't intend to support multiple POWs in bitcoin. I'm fine with moving these to a seperate file, main is much too large and this is a clearly delimited separable piece of functionality. Don't move ScanHash_CryptoPP from miner.cpp here: it's a static function and keeping the internal miner functions together makes sense. |
|
Ok, I'll just leave it as it is and move nTargetTimespan, nTargetSpacing and nInterval to CChainParams in another pull request after/if this one gets merged. More concretely, I want to avoid merge conflicts with #3824 and this is not a high priority change anyway, just refactoring to improve readability and move towards a more modular codebase. |
|
@jtimon I think you should just go ahead an commit the change to move |
|
It may create a merge conflict with the other PR because it edits the same interface (abstract class) CChainParams, but they should be easily solvable so I moved the constants as suggested. |
|
Nice. This PR looks good to me (untested but the diff seems pretty straightforward). |
|
Rebase please? |
|
Rebased |
|
Untested ACK... though I did a line-by-line scan to look for aberrant changes mixed into the code movement. |
|
While rebasing it came to mind that maybe these pow-specific constants don't really belong to chainparams. There could be a pow class with them as arguments and having these functions as methods. Just to be clear, Freicoin uses the same SHA256 pow as bitcoin, and although I got to this pool request by looking for the places I would need to touch for implementing private chains (also non-bitcoinish), the main objective of the PR is nothing but getting things that belong together out of main. |
|
I don't think usefulness for derived codebases is a priority here. If code quality improvements benefit them, so much the better, but I don't think we should make our code more complex to accommodate potential forks... I like this because it moves responsibilities away from main, and the code looks sane to me (though I'd like to go over it line by line). |
|
Thank you for the feedback, makes sense. |
|
@sipa Agree it is not a primary priority. If we can refactor, make our code more modular, and make life less difficult for clones/forks, that is good. |
|
Just for the record, I have been running two nodes with this patch since Jun 1 with no problems or funny stuff in the logs. |
|
@Drak thanks for the testing. |
|
I have also moved UpdateTime. |
|
I'm working on more changes so I will close this for now. I will reopen it soon. |
|
@jtimon The PR looks good, but generally a PR like this should just be shuffing code. Makes it easier to read the diff and know what is going on. referring specifically to 3931601 which should be the subject of a separate PR. |
|
No problem, I will separate the commits in 2 different PR. |
|
Ok, looks good to me. ACK. |
|
Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/p3839_fd704c7b2c5ab8b24b1829f000b829d7156b8b3c/ for binaries and test log. |
|
@laanwj is there anything holding up this being merged? |
|
@Drak No, looks good to me now. I'll check the code moves and try to merge this today. |
I'm not sure if ScanHash_CryptoPP on miner.cpp would fit here too.