diff --git a/src/chainparams.cpp b/src/chainparams.cpp index cfb48138c..d9a566646 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -134,7 +134,6 @@ public: pchMessageStart[2] = 0x22; pchMessageStart[3] = 0x05; nDefaultPort = 15714; - nMaxTipAge = 24 * 60 * 60; nPruneAfterHeight = 100000; genesis = CreateGenesisBlock(1393221600, 164482, 0x1e0fffff, 1, 0); @@ -219,7 +218,6 @@ public: pchMessageStart[2] = 0xc0; pchMessageStart[3] = 0xef; nDefaultPort = 25714; - nMaxTipAge = 0x7fffffff; // The best chain should have at least this much work. consensus.nMinimumChainWork = uint256S("0x00"); @@ -318,7 +316,6 @@ public: pchMessageStart[2] = 0x22; pchMessageStart[3] = 0x06; nDefaultPort = 25714; - nMaxTipAge = 0x7fffffff; nPruneAfterHeight = 100000; genesis = CreateGenesisBlock(1393221600, 216178, 0x1f00ffff, 1, 0); diff --git a/src/chainparams.h b/src/chainparams.h index eadea1b76..774593cfa 100644 --- a/src/chainparams.h +++ b/src/chainparams.h @@ -64,7 +64,6 @@ public: bool DefaultConsistencyChecks() const { return fDefaultConsistencyChecks; } /** Policy: Filter transactions that do not match well-defined patterns */ bool RequireStandard() const { return fRequireStandard; } - int64_t MaxTipAge() const { return nMaxTipAge; } uint64_t PruneAfterHeight() const { return nPruneAfterHeight; } /** Make miner stop after a block is found. In RPC, don't return until nGenProcLimit blocks are generated */ bool MineBlocksOnDemand() const { return fMineBlocksOnDemand; } @@ -84,7 +83,6 @@ protected: Consensus::Params consensus; CMessageHeader::MessageStartChars pchMessageStart; int nDefaultPort; - long nMaxTipAge; uint64_t nPruneAfterHeight; std::vector vSeeds; std::vector base58Prefixes[MAX_BASE58_TYPES]; diff --git a/src/init.cpp b/src/init.cpp index 88e6c1abb..0ffc86e8b 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -429,6 +429,7 @@ std::string HelpMessage(HelpMessageMode mode) strUsage += HelpMessageOpt("-limitfreerelay=", strprintf("Continuously rate-limit free transactions to *1000 bytes per minute (default: %u)", DEFAULT_LIMITFREERELAY)); strUsage += HelpMessageOpt("-relaypriority", strprintf("Require high priority for relaying free or low-fee transactions (default: %u)", DEFAULT_RELAYPRIORITY)); strUsage += HelpMessageOpt("-maxsigcachesize=", strprintf("Limit size of signature cache to MiB (default: %u)", DEFAULT_MAX_SIG_CACHE_SIZE)); + strUsage += HelpMessageOpt("-maxtipage=", strprintf("Maximum tip age in seconds to consider node in initial block download (default: %u)", DEFAULT_MAX_TIP_AGE)); } strUsage += HelpMessageOpt("-minrelaytxfee=", strprintf(_("Fees (in %s/kB) smaller than this are considered zero fee for relaying, mining and transaction creation (default: %s)"), CURRENCY_UNIT, FormatMoney(DEFAULT_MIN_RELAY_TX_FEE))); @@ -984,6 +985,8 @@ bool AppInit2(Config& config, boost::thread_group& threadGroup, CScheduler& sche fEnableReplacement = (std::find(vstrReplacementModes.begin(), vstrReplacementModes.end(), "fee") != vstrReplacementModes.end()); } + nMaxTipAge = GetArg("-maxtipage", DEFAULT_MAX_TIP_AGE); + // ********************************************************* Step 4: application initialization: dir lock, daemonize, pidfile, debug log // Initialize elliptic curve code diff --git a/src/main.cpp b/src/main.cpp index eaba495a3..be52f7766 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -90,6 +90,9 @@ size_t nCoinCacheUsage = 5000 * 300; uint64_t nPruneTarget = 0; bool fEnableReplacement = DEFAULT_ENABLE_REPLACEMENT; +/* If the tip is older than this (in seconds), the node is considered to be in initial block download. + */ +int64_t nMaxTipAge = DEFAULT_MAX_TIP_AGE; CFeeRate minRelayTxFee = CFeeRate(DEFAULT_MIN_RELAY_TX_FEE); CAmount maxTxFee = DEFAULT_TRANSACTION_MAXFEE; @@ -1760,7 +1763,7 @@ bool IsInitialBlockDownload() if (lockIBDState) return false; bool state = (chainActive.Height() < pindexBestHeader->nHeight - 24 * 6 || - pindexBestHeader->GetBlockTime() < GetTime() - chainParams.MaxTipAge()); + pindexBestHeader->GetBlockTime() < GetTime() - nMaxTipAge); if (!state) lockIBDState = true; return state; diff --git a/src/main.h b/src/main.h index 0596389af..d03744e92 100644 --- a/src/main.h +++ b/src/main.h @@ -118,6 +118,7 @@ static const int64_t BLOCK_DOWNLOAD_TIMEOUT_PER_PEER = 500000; static const unsigned int DEFAULT_LIMITFREERELAY = 15; static const bool DEFAULT_RELAYPRIORITY = true; +static const int64_t DEFAULT_MAX_TIP_AGE = 24 * 60 * 60; /** Default for -permitbaremultisig */ static const bool DEFAULT_PERMIT_BAREMULTISIG = true; @@ -172,6 +173,7 @@ extern CFeeRate minRelayTxFee; extern CAmount maxTxFee; extern bool fEnableReplacement; extern int64_t nLastCoinStakeSearchInterval; +extern int64_t nMaxTipAge; /** Best header we've seen so far (used for getheaders queries' starting points). */ extern CBlockIndex *pindexBestHeader;