aboutsummaryrefslogtreecommitdiff
path: root/src/node
diff options
context:
space:
mode:
authorSjors Provoost <sjors@sprovoost.nl>2024-08-20 10:45:04 +0200
committerSjors Provoost <sjors@sprovoost.nl>2024-08-20 18:51:37 +0200
commit59ff17e5af4e382cbe16f183767beef1bdcd9131 (patch)
treeb0680f22dfb41f8fba0139b23ef7e55e8e368924 /src/node
parente929054e12210353812f440c685a23329e7040f7 (diff)
miner: adjust clock to timewarp rule
Diffstat (limited to 'src/node')
-rw-r--r--src/node/miner.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/node/miner.cpp b/src/node/miner.cpp
index fa2d979b86..5c476e154f 100644
--- a/src/node/miner.cpp
+++ b/src/node/miner.cpp
@@ -33,6 +33,14 @@ int64_t UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParam
int64_t nOldTime = pblock->nTime;
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.
+ const int height{pindexPrev->nHeight + 1};
+ if (height % consensusParams.DifficultyAdjustmentInterval() == 0) {
+ nNewTime = std::max<int64_t>(nNewTime, pindexPrev->GetBlockTime() - MAX_TIMEWARP);
+ }
+ }
+
if (nOldTime < nNewTime) {
pblock->nTime = nNewTime;
}