From a3dd53f40aaedd28bd4d0fc720f034492f7ded81 Mon Sep 17 00:00:00 2001 From: sunerok Date: Thu, 5 Apr 2018 14:25:36 +0200 Subject: [PATCH] change AcceptBlock() rules at 2040000 --- src/main.cpp | 16 ++++++++++++++-- src/main.h | 3 ++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 0a9abe1a9..453e2e7ba 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2304,8 +2304,20 @@ bool CBlock::AcceptBlock() return DoS(100, error("AcceptBlock() : incorrect %s", IsProofOfWork() ? "proof-of-work" : "proof-of-stake")); // Check timestamp against prev - if (GetBlockTime() <= pindexPrev->GetMedianTimePast() || GetBlockTime() + nMaxClockDrift < pindexPrev->GetBlockTime()) - return error("AcceptBlock() : block's timestamp is too early"); + if (nHeight <= TIMESTAMP_RULES_SWITCH_BLOCK) + { + const unsigned oldMaxDrift = 7200; //2 hours + if (GetBlockTime() <= pindexPrev->GetMedianTimePast() || GetBlockTime() + oldMaxDrift < pindexPrev->GetBlockTime()) + return error("AcceptBlock() : block's timestamp is too early"); + } + else + { + if (GetBlockTime() < pindexPrev->GetBlockTime()) + return error("AcceptBlock() : block's timestamp is too early"); + + if (GetBlockTime() > GetAdjustedTime() + nMaxClockDrift) + return error("AcceptBlock() : block too much in the future"); + } // Check that all transactions are finalized BOOST_FOREACH(const CTransaction& tx, vtx) diff --git a/src/main.h b/src/main.h index dcda20c42..9856af00b 100644 --- a/src/main.h +++ b/src/main.h @@ -31,6 +31,7 @@ class CNode; static const int MULTI_ALGO_SWITCH_BLOCK = 340000; static const int STEALTH_TX_SWITCH_BLOCK = 1824150; +static const int TIMESTAMP_RULES_SWITCH_BLOCK = 2040000; static const unsigned int MAX_BLOCK_SIZE = 1000000; static const unsigned int MAX_BLOCK_SIZE_GEN = MAX_BLOCK_SIZE/2; static const unsigned int MAX_BLOCK_SIGOPS = MAX_BLOCK_SIZE/50; @@ -56,7 +57,7 @@ static const int fHaveUPnP = false; static const uint256 hashGenesisBlockOfficial("0x00000fc63692467faeb20cdb3b53200dc601d75bdfa1001463304cc790d77278"); static const uint256 hashGenesisBlockTestNet("0x65b4e101cacf3e1e4f3a9237e3a74ffd1186e595d8b78fa8ea22c21ef5bf9347"); -static const int64 nMaxClockDrift = 2 * 60 * 60; // two hours - will mod into fork +static const int64 nMaxClockDrift = 60 * 20; // 20 minutes extern CScript COINBASE_FLAGS;