Skip to content

Commit 47c5ed1

Browse files
committed
Merge pull request #7208
64360f1 Make max tip age an option instead of chainparam (Wladimir J. van der Laan)
2 parents c851d8d + 64360f1 commit 47c5ed1

File tree

5 files changed

+9
-6
lines changed

5 files changed

+9
-6
lines changed

src/chainparams.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ class CMainParams : public CChainParams {
9292
pchMessageStart[3] = 0xd9;
9393
vAlertPubKey = ParseHex("04fc9702847840aaf195de8442ebecedf5b095cdbb9bc716bda9110971b28a49e0ead8564ff0db22209e0374782c093bb899692d524e9d6a6956e7c5ecbcd68284");
9494
nDefaultPort = 8333;
95-
nMaxTipAge = 24 * 60 * 60;
9695
nPruneAfterHeight = 100000;
9796

9897
genesis = CreateGenesisBlock(1231006505, 2083236893, 0x1d00ffff, 1, 50 * COIN);
@@ -169,7 +168,6 @@ class CTestNetParams : public CChainParams {
169168
pchMessageStart[3] = 0x07;
170169
vAlertPubKey = ParseHex("04302390343f91cc401d56d68b123028bf52e5fca1939df127f63c6467cdf9c8e2c14b61104cf817d0b780da337893ecc4aaff1309e536162dabbdb45200ca2b0a");
171170
nDefaultPort = 18333;
172-
nMaxTipAge = 0x7fffffff;
173171
nPruneAfterHeight = 1000;
174172

175173
genesis = CreateGenesisBlock(1296688602, 414098458, 0x1d00ffff, 1, 50 * COIN);
@@ -232,7 +230,6 @@ class CRegTestParams : public CChainParams {
232230
pchMessageStart[1] = 0xbf;
233231
pchMessageStart[2] = 0xb5;
234232
pchMessageStart[3] = 0xda;
235-
nMaxTipAge = 24 * 60 * 60;
236233
nDefaultPort = 18444;
237234
nPruneAfterHeight = 1000;
238235

src/chainparams.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ class CChainParams
6464
bool DefaultConsistencyChecks() const { return fDefaultConsistencyChecks; }
6565
/** Policy: Filter transactions that do not match well-defined patterns */
6666
bool RequireStandard() const { return fRequireStandard; }
67-
int64_t MaxTipAge() const { return nMaxTipAge; }
6867
uint64_t PruneAfterHeight() const { return nPruneAfterHeight; }
6968
/** Make miner stop after a block is found. In RPC, don't return until nGenProcLimit blocks are generated */
7069
bool MineBlocksOnDemand() const { return fMineBlocksOnDemand; }
@@ -84,7 +83,6 @@ class CChainParams
8483
//! Raw pub key bytes for the broadcast alert signing key.
8584
std::vector<unsigned char> vAlertPubKey;
8685
int nDefaultPort;
87-
long nMaxTipAge;
8886
uint64_t nPruneAfterHeight;
8987
std::vector<CDNSSeedData> vSeeds;
9088
std::vector<unsigned char> base58Prefixes[MAX_BASE58_TYPES];

src/init.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,7 @@ std::string HelpMessage(HelpMessageMode mode)
465465
strUsage += HelpMessageOpt("-limitfreerelay=<n>", strprintf("Continuously rate-limit free transactions to <n>*1000 bytes per minute (default: %u)", DEFAULT_LIMITFREERELAY));
466466
strUsage += HelpMessageOpt("-relaypriority", strprintf("Require high priority for relaying free or low-fee transactions (default: %u)", DEFAULT_RELAYPRIORITY));
467467
strUsage += HelpMessageOpt("-maxsigcachesize=<n>", strprintf("Limit size of signature cache to <n> MiB (default: %u)", DEFAULT_MAX_SIG_CACHE_SIZE));
468+
strUsage += HelpMessageOpt("-maxtipage=<n>", strprintf("Maximum tip age in seconds to consider node in initial block download (default: %u)", DEFAULT_MAX_TIP_AGE));
468469
}
469470
strUsage += HelpMessageOpt("-minrelaytxfee=<amt>", strprintf(_("Fees (in %s/kB) smaller than this are considered zero fee for relaying, mining and transaction creation (default: %s)"),
470471
CURRENCY_UNIT, FormatMoney(DEFAULT_MIN_RELAY_TX_FEE)));
@@ -1025,6 +1026,8 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
10251026
if (GetBoolArg("-peerbloomfilters", true))
10261027
nLocalServices |= NODE_BLOOM;
10271028

1029+
nMaxTipAge = GetArg("-maxtipage", DEFAULT_MAX_TIP_AGE);
1030+
10281031
// ********************************************************* Step 4: application initialization: dir lock, daemonize, pidfile, debug log
10291032

10301033
// Initialize elliptic curve code

src/main.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ bool fCheckpointsEnabled = DEFAULT_CHECKPOINTS_ENABLED;
7575
size_t nCoinCacheUsage = 5000 * 300;
7676
uint64_t nPruneTarget = 0;
7777
bool fAlerts = DEFAULT_ALERTS;
78+
/* If the tip is older than this (in seconds), the node is considered to be in initial block download.
79+
*/
80+
int64_t nMaxTipAge = DEFAULT_MAX_TIP_AGE;
7881

7982
/** Fees smaller than this (in satoshi) are considered zero fee (for relaying, mining and transaction creation) */
8083
CFeeRate minRelayTxFee = CFeeRate(DEFAULT_MIN_RELAY_TX_FEE);
@@ -1377,7 +1380,7 @@ bool IsInitialBlockDownload()
13771380
if (lockIBDState)
13781381
return false;
13791382
bool state = (chainActive.Height() < pindexBestHeader->nHeight - 24 * 6 ||
1380-
pindexBestHeader->GetBlockTime() < GetTime() - chainParams.MaxTipAge());
1383+
pindexBestHeader->GetBlockTime() < GetTime() - nMaxTipAge);
13811384
if (!state)
13821385
lockIBDState = true;
13831386
return state;

src/main.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ static const unsigned int AVG_INVENTORY_BROADCAST_INTERVAL = 5;
9797

9898
static const unsigned int DEFAULT_LIMITFREERELAY = 15;
9999
static const bool DEFAULT_RELAYPRIORITY = true;
100+
static const int64_t DEFAULT_MAX_TIP_AGE = 24 * 60 * 60;
100101

101102
/** Default for -permitbaremultisig */
102103
static const bool DEFAULT_PERMIT_BAREMULTISIG = true;
@@ -137,6 +138,7 @@ extern bool fCheckpointsEnabled;
137138
extern size_t nCoinCacheUsage;
138139
extern CFeeRate minRelayTxFee;
139140
extern bool fAlerts;
141+
extern int64_t nMaxTipAge;
140142

141143
/** Best header we've seen so far (used for getheaders queries' starting points). */
142144
extern CBlockIndex *pindexBestHeader;

0 commit comments

Comments
 (0)