Skip to content

Commit

Permalink
[Backport] Max tip age to consider a node in IBD status customizable.…
Browse files Browse the repository at this point in the history
… Backport from bitcoin#bitcoin#7208.
  • Loading branch information
furszy committed Jun 15, 2019
1 parent c0233e4 commit 46ba7a2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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=<n>", strprintf(_("Limit size of signature cache to <n> entries (default: %u)"), 50000));
}
strUsage += HelpMessageOpt("-maxtipage=<n>", strprintf("Maximum tip age in seconds to consider node in initial block download (default: %u)", DEFAULT_MAX_TIP_AGE));
strUsage += HelpMessageOpt("-minrelaytxfee=<amt>", 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)) {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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));
}
Expand Down
5 changes: 4 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions src/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit 46ba7a2

Please sign in to comment.