From 5d855091429929be01a241f33ca3be00063eb91c Mon Sep 17 00:00:00 2001 From: lateminer <9951982+lateminer@users.noreply.github.com> Date: Wed, 27 Mar 2019 22:55:43 +0300 Subject: [PATCH] Ban peers that fail to pass future drift check --- src/main.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index e3263e3f7..3bb531a1b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3562,19 +3562,18 @@ bool ContextualCheckBlockHeader(const CBlockHeader& block, CValidationState& sta // Preliminary check of pos timestamp if (nHeight > consensusParams.nLastPOWBlock && !CheckStakeBlockTimestamp(block.GetBlockTime())) - return state.DoS(100, error("%s: incorrect pos block timestamp", __func__), + return state.DoS(50, error("%s: incorrect pos block timestamp", __func__), REJECT_INVALID, "bad-pos-time"); + // Check timestamp + if (block.GetBlockTime() > FutureDrift(GetAdjustedTime())) + return state.DoS(50, error("%s: block timestamp too far in the future", __func__), + REJECT_INVALID, "time-too-new"); + // Check timestamp against prev if (block.GetBlockTime() <= pindexPrev->GetPastTimeLimit()) return state.Invalid(error("%s: block's timestamp is too early", __func__), REJECT_INVALID, "time-too-old"); - - // Check timestamp - if (block.GetBlockTime() > FutureDrift(GetAdjustedTime())) - return state.Invalid(error("%s: block timestamp too far in the future", __func__), - REJECT_INVALID, "time-too-new"); - /* // Reject outdated version blocks when 95% (75% on testnet) of the network has upgraded: for (int32_t version = 2; version < 5; ++version) // check for version 2, 3 and 4 upgrades