Continue proof of work encapsulation#5171
Conversation
src/pow.h
Outdated
There was a problem hiding this comment.
Can you explain the nit a little bit more?
|
utACK, apart from the above nits. |
|
Added commit to correct nits (plus fix a missing include). |
|
ping |
|
Rebased for clarity after #5170 being merged. |
|
Needed rebase. |
|
This definitely makes the code more readable, it rebases on 0.10 without problems and its the sort of change that helps to isolate and track pow related operations. It adds the following functions to pow.h: bool CheckChallenge(const CBlockHeader& block, const CBlockIndex& indexLast);
void ResetChallenge(CBlockHeader& block, const CBlockIndex& indexLast);
/** Avoid using these functions when possible */
double GetChallengeDifficulty(const CBlockIndex* blockindex);
std::string GetChallengeStr(const CBlockIndex& block);
std::string GetChallengeStrHex(const CBlockIndex& block);
uint32_t GetNonce(const CBlockHeader& block);
void SetNonce(CBlockHeader& block, uint32_t nNonce);It may be desirable to add to the comment: brief reason why to avoid those functions and a mention where they are currently called (rpcblockchain.cpp and rpcmining.cpp). |
|
NACK "more readable" is not a good justification to be messing around with this code. If anything, I'd argue it makes the code less readable as what it's actually doing has been obscured by more layers of abstraction. |
|
Well, it introduces the |
|
Closing for now, at least until #5599 has been merged (if it gets merged) and I can propose something more complete. |
It is built on top of #5170, replaces #4506 and continues #4377.