Permalink
Browse files

new future time allowable window for a block to reject from block 200k

  • Loading branch information...
npq7721 committed Sep 28, 2018
1 parent 4b0d127 commit 90e2dcbe60aa413b4efba2ad4518bcd003a3dca0
Showing with 10 additions and 3 deletions.
  1. +1 −1 configure.ac
  2. +1 −0 src/chain.h
  3. +3 −0 src/chainparams.cpp
  4. +3 −0 src/chainparams.h
  5. +2 −2 src/validation.cpp
@@ -3,7 +3,7 @@ AC_PREREQ([2.60])
define(_CLIENT_VERSION_MAJOR, 0)
define(_CLIENT_VERSION_MINOR, 15)
define(_CLIENT_VERSION_REVISION, 99)
define(_CLIENT_VERSION_BUILD, 5)
define(_CLIENT_VERSION_BUILD, 6)
define(_CLIENT_VERSION_IS_RELEASE, true)
define(_COPYRIGHT_YEAR, 2018)
define(_COPYRIGHT_HOLDERS,[The %s developers])
@@ -20,6 +20,7 @@
* current network-adjusted time before the block will be accepted.
*/
static const int64_t MAX_FUTURE_BLOCK_TIME = 2 * 60 * 60;
static const int64_t MAX_FUTURE_LWMA_TIME = MAX_FUTURE_BLOCK_TIME / 10;
/**
* Timestamp window used as a grace period by code that compares external
@@ -164,6 +164,7 @@ class CMainParams : public CChainParams {
pchMessageStart[3] = 0x4e;
nDefaultPort = 8757;
nPruneAfterHeight = 100000;
newFutureWindowBlock = 200000;
genesis = CreateGenesisBlock(1521661111, 17434278, 0x1e00ffff, 4, 5000 * COIN);
@@ -314,6 +315,7 @@ class CTestNetParams : public CChainParams {
pchMessageStart[3] = 0x54;
nDefaultPort = 18757;
nPruneAfterHeight = 1000;
newFutureWindowBlock = 1;
genesis = CreateGenesisBlock(1521662222, 32516807, 0x1e00ffff, 4, 5000 * COIN);
consensus.hashGenesisBlock = genesis.GetHash();
@@ -400,6 +402,7 @@ class CRegTestParams : public CChainParams {
pchMessageStart[3] = 0x57;
nDefaultPort = 18444;
nPruneAfterHeight = 1000;
newFutureWindowBlock = 1;
genesis = CreateGenesisBlock(1521663333, 5898126, 0x207fffff, 4, 5000 * COIN);
consensus.hashGenesisBlock = genesis.GetHash();
@@ -89,6 +89,8 @@ class CChainParams
bool BIP65();
bool BIP66();
bool CSVEnabled() const;
uint64_t getNewFutureWindowBlock() const {return this->newFutureWindowBlock;};
protected:
CChainParams() {}
@@ -108,6 +110,7 @@ class CChainParams
bool fMiningRequiresPeers;
CCheckpointData checkpointData;
ChainTxData chainTxData;
uint64_t newFutureWindowBlock;
};
/**
@@ -2963,9 +2963,9 @@ static bool ContextualCheckBlockHeader(const CBlockHeader& block, CValidationSta
// Check timestamp against prev
if (block.GetBlockTime() <= pindexPrev->GetMedianTimePast())
return state.Invalid(false, REJECT_INVALID, "time-too-old", "block's timestamp is too early");
int64_t futureTimeWindow = nHeight > params.getNewFutureWindowBlock() ? MAX_FUTURE_LWMA_TIME : MAX_FUTURE_BLOCK_TIME;
// Check timestamp
if (block.GetBlockTime() > nAdjustedTime + MAX_FUTURE_BLOCK_TIME)
if (block.GetBlockTime() > nAdjustedTime + futureTimeWindow)
return state.Invalid(false, REJECT_INVALID, "time-too-new", "block timestamp too far in the future");
// Reject outdated version blocks when 95% (75% on testnet) of the network has upgraded:

0 comments on commit 90e2dcb

Please sign in to comment.