Move UpdateTime to pow

This commit is contained in:
jtimon
2014-06-28 14:03:06 +02:00
parent 92b3d3630d
commit c2c02f3fa9
6 changed files with 15 additions and 33 deletions

View File

@@ -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);
}