diff --git a/src/init.cpp b/src/init.cpp index 104033602b5f2..ae0b37989a86a 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -520,6 +520,7 @@ std::string HelpMessage(HelpMessageMode mode) strUsage += HelpMessageOpt("-relaypriority", strprintf(_("Require high priority for relaying free or low-fee transactions (default:%u)"), 1)); strUsage += HelpMessageOpt("-maxsigcachesize=", strprintf(_("Limit size of signature cache to entries (default: %u)"), 50000)); } + 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 PIV/Kb) smaller than this are considered zero fee for relaying (default: %s)"), FormatMoney(::minRelayTxFee.GetFeePerK()))); strUsage += HelpMessageOpt("-printtoconsole", strprintf(_("Send trace/debug info to console instead of debug.log file (default: %u)"), 0)); if (GetBoolArg("-help-debug", false)) { @@ -1019,6 +1020,8 @@ bool AppInit2() } + nMaxTipAge = GetArg("-maxtipage", DEFAULT_MAX_TIP_AGE); + // ********************************************************* Step 4: application initialization: dir lock, daemonize, pidfile, debug log // Initialize elliptic curve code @@ -2025,7 +2028,7 @@ bool AppInit2() // Run a thread to flush wallet periodically threadGroup.create_thread(boost::bind(&ThreadFlushWalletDB, boost::ref(pwalletMain->strWalletFile))); - if (GetBoolArg("-precompute", true)) { + if (GetBoolArg("-precompute", false)) { // Run a thread to precompute any zPIV spends threadGroup.create_thread(boost::bind(&ThreadPrecomputeSpends)); } diff --git a/src/main.cpp b/src/main.cpp index a3acf0c51e9cf..a153cff33178b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -81,6 +81,9 @@ unsigned int nCoinCacheSize = 5000; bool fAlerts = DEFAULT_ALERTS; bool fClearSpendCache = false; +/* 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; + unsigned int nStakeMinAge = 60 * 60; int64_t nReserveBalance = 0; @@ -2304,7 +2307,7 @@ bool IsInitialBlockDownload() if (lockIBDState) return false; bool state = (chainActive.Height() < pindexBestHeader->nHeight - 24 * 6 || - pindexBestHeader->GetBlockTime() < GetTime() - 6 * 60 * 60); // ~144 blocks behind -> 2 x fork detection time + pindexBestHeader->GetBlockTime() < GetTime() - nMaxTipAge); if (!state) lockIBDState = true; return state; diff --git a/src/main.h b/src/main.h index 8322998647aa4..0e246ddd433c0 100644 --- a/src/main.h +++ b/src/main.h @@ -111,6 +111,8 @@ static const unsigned int MAX_REJECT_MESSAGE_LENGTH = 111; static const bool DEFAULT_PEERBLOOMFILTERS = true; static const bool DEFAULT_PEERBLOOMFILTERS_ZC = false; +/** If the tip is older than this (in seconds), the node is considered to be in initial block download. */ +static const int64_t DEFAULT_MAX_TIP_AGE = 24 * 60 * 60; /** Default for -blockspamfilter, use header spam filter */ static const bool DEFAULT_BLOCK_SPAM_FILTER = true; @@ -159,6 +161,7 @@ extern bool fCheckBlockIndex; extern unsigned int nCoinCacheSize; extern CFeeRate minRelayTxFee; extern bool fAlerts; +extern int64_t nMaxTipAge; extern bool fVerifyingBlocks; extern bool fClearSpendCache;