aboutsummaryrefslogtreecommitdiff
path: root/src/pow.cpp
diff options
context:
space:
mode:
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);
+}