aboutsummaryrefslogtreecommitdiff
path: root/src/pow.cpp
diff options
context:
space:
mode:
authorWladimir J. van der Laan <[email protected]>2015-03-06 15:26:44 +0100
committerWladimir J. van der Laan <[email protected]>2015-03-06 15:27:00 +0100
commitee9f2bfa7b7a629afdcc6d3ddc3b798acdf005ed (patch)
tree5d38178be834792d85b2d52392b0bb20f3f365ea /src/pow.cpp
parentQT: remove unused parameter (diff)
parentAdd unit tests for next difficulty calculations (diff)
downloaddiscoin-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.cpp7
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;