mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-12-07 03:03:58 +01:00
Move UpdateTime to pow
This commit is contained in:
10
src/pow.cpp
10
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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user