aboutsummaryrefslogtreecommitdiff
path: root/src/pow.cpp
diff options
context:
space:
mode:
authorjtimon <jtimon@monetize.io>2014-06-28 14:03:06 +0200
committerjtimon <jtimon@monetize.io>2014-08-23 13:21:50 +0200
commitc2c02f3fa99385f5a5be722fda6f71522c93bdaa (patch)
tree608b76aa8e523a4118f569518bf5150e85d77c48 /src/pow.cpp
parent92b3d3630d6d63305bec136a23c7be4cb2bb2652 (diff)
Move UpdateTime to pow
Diffstat (limited to 'src/pow.cpp')
-rw-r--r--src/pow.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/pow.cpp b/src/pow.cpp
index c0d0a7ca20..a99c582d7d 100644
--- a/src/pow.cpp
+++ b/src/pow.cpp
@@ -8,6 +8,7 @@
#include "chainparams.h"
#include "core.h"
#include "main.h"
+#include "timedata.h"
#include "uint256.h"
unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHeader *pblock)
@@ -117,3 +118,12 @@ unsigned int ComputeMinWork(unsigned int nBase, int64_t nTime)
bnResult = bnLimit;
return bnResult.GetCompact();
}
+
+void UpdateTime(CBlockHeader* pblock, const CBlockIndex* pindexPrev)
+{
+ pblock->nTime = std::max(pindexPrev->GetMedianTimePast()+1, GetAdjustedTime());
+
+ // Updating time can change work required on testnet:
+ if (Params().AllowMinDifficultyBlocks())
+ pblock->nBits = GetNextWorkRequired(pindexPrev, pblock);
+}