X-Git-Url: https://git.novaco.in/?p=novacoin.git;a=blobdiff_plain;f=src%2Fmain.cpp;h=b8577398aea3068b3102d5e508b27665bb07d0ee;hp=7d0ce9869724940ed815616d7d3dbe3e809579c4;hb=fe3160e5c4a0046b4f97ec6d32d280aaa6ecc74c;hpb=5b098a8ec26ef68b65dd42a04246418a871e9cd9 diff --git a/src/main.cpp b/src/main.cpp index 7d0ce98..b857739 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2335,10 +2335,19 @@ bool CBlock::AcceptBlock() if (nBits != GetNextTargetRequired(pindexPrev, IsProofOfStake())) return DoS(100, error("AcceptBlock() : incorrect %s", IsProofOfWork() ? "proof-of-work" : "proof-of-stake")); + int64_t nMedianTimePast = pindexPrev->GetMedianTimePast(); + int nMaxOffset = 12 * 3600; // 12 hours + if (pindexPrev->nTime < 1450569600) + nMaxOffset = 7 * 86400; // One week until 20 Dec, 2015 + // Check timestamp against prev - if (GetBlockTime() <= pindexPrev->GetMedianTimePast() || FutureDrift(GetBlockTime()) < pindexPrev->GetBlockTime()) + if (GetBlockTime() <= nMedianTimePast || FutureDrift(GetBlockTime()) < pindexPrev->GetBlockTime()) return error("AcceptBlock() : block's timestamp is too early"); + // Don't accept blocks with future timestamps + if (pindexPrev->nHeight > 1 && nMedianTimePast + nMaxOffset < GetBlockTime()) + return error("AcceptBlock() : block's timestamp is too far in the future"); + // Check that all transactions are finalized BOOST_FOREACH(const CTransaction& tx, vtx) if (!tx.IsFinal(nHeight, GetBlockTime()))