miner: never create a template which exploits the timewarp bug
This commit is contained in:
1 parent
f7144b24be
commit
733fa0b0a1
1 file changed
+4
-6
+4
-6
@@ -33,12 +33,10 @@ int64_t UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParam
|
|||||||
int64_t nOldTime = pblock->nTime;
|
int64_t nOldTime = pblock->nTime;
|
||||||
int64_t nNewTime{std::max<int64_t>(pindexPrev->GetMedianTimePast() + 1, TicksSinceEpoch<std::chrono::seconds>(NodeClock::now()))};
|
int64_t nNewTime{std::max<int64_t>(pindexPrev->GetMedianTimePast() + 1, TicksSinceEpoch<std::chrono::seconds>(NodeClock::now()))};
|
||||||
|
|
||||||
if (consensusParams.enforce_BIP94) {
|
// Height of block to be mined.
|
||||||
// Height of block to be mined.
|
const int height{pindexPrev->nHeight + 1};
|
||||||
const int height{pindexPrev->nHeight + 1};
|
if (height % consensusParams.DifficultyAdjustmentInterval() == 0) {
|
||||||
if (height % consensusParams.DifficultyAdjustmentInterval() == 0) {
|
nNewTime = std::max<int64_t>(nNewTime, pindexPrev->GetBlockTime() - MAX_TIMEWARP);
|
||||||
nNewTime = std::max<int64_t>(nNewTime, pindexPrev->GetBlockTime() - MAX_TIMEWARP);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nOldTime < nNewTime) {
|
if (nOldTime < nNewTime) {
|
||||||
|
|||||||
Reference in new issue
Block a user