diff options
| author | Wladimir J. van der Laan <[email protected]> | 2015-03-06 15:26:44 +0100 |
|---|---|---|
| committer | Wladimir J. van der Laan <[email protected]> | 2015-03-06 15:27:00 +0100 |
| commit | ee9f2bfa7b7a629afdcc6d3ddc3b798acdf005ed (patch) | |
| tree | 5d38178be834792d85b2d52392b0bb20f3f365ea /src/pow.cpp | |
| parent | QT: remove unused parameter (diff) | |
| parent | Add unit tests for next difficulty calculations (diff) | |
| download | discoin-ee9f2bfa7b7a629afdcc6d3ddc3b798acdf005ed.tar.xz discoin-ee9f2bfa7b7a629afdcc6d3ddc3b798acdf005ed.zip | |
Merge pull request #5813
34e5015 Add unit tests for next difficulty calculations (Ross Nicoll)
Diffstat (limited to 'src/pow.cpp')
| -rw-r--r-- | src/pow.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/pow.cpp b/src/pow.cpp index 6dd5c4c12..b75b293c9 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -48,8 +48,13 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHead pindexFirst = pindexFirst->pprev; assert(pindexFirst); + return CalculateNextWorkRequired(pindexLast, pindexFirst->GetBlockTime()); +} + +unsigned int CalculateNextWorkRequired(const CBlockIndex* pindexLast, int64_t nFirstBlockTime) +{ // Limit adjustment step - int64_t nActualTimespan = pindexLast->GetBlockTime() - pindexFirst->GetBlockTime(); + int64_t nActualTimespan = pindexLast->GetBlockTime() - nFirstBlockTime; LogPrintf(" nActualTimespan = %d before bounds\n", nActualTimespan); if (nActualTimespan < Params().TargetTimespan()/4) nActualTimespan = Params().TargetTimespan()/4; |