Skip to content

Commit 33d6825

Browse files
committed
Bugfix: Allow mining on top of old tip blocks for testnet (fixes testnet-in-a-box use case)
1 parent 87a797a commit 33d6825

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

src/chainparams.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ class CMainParams : public CChainParams {
5151
vAlertPubKey = ParseHex("04fc9702847840aaf195de8442ebecedf5b095cdbb9bc716bda9110971b28a49e0ead8564ff0db22209e0374782c093bb899692d524e9d6a6956e7c5ecbcd68284");
5252
nDefaultPort = 8333;
5353
nMinerThreads = 0;
54+
nMaxTipAge = 24 * 60 * 60;
5455
nPruneAfterHeight = 100000;
5556

5657
/**
@@ -147,6 +148,7 @@ class CTestNetParams : public CMainParams {
147148
vAlertPubKey = ParseHex("04302390343f91cc401d56d68b123028bf52e5fca1939df127f63c6467cdf9c8e2c14b61104cf817d0b780da337893ecc4aaff1309e536162dabbdb45200ca2b0a");
148149
nDefaultPort = 18333;
149150
nMinerThreads = 0;
151+
nMaxTipAge = 0x7fffffff;
150152
nPruneAfterHeight = 1000;
151153

152154
//! Modify the testnet genesis block so the timestamp is valid for a later start.
@@ -206,6 +208,7 @@ class CRegTestParams : public CTestNetParams {
206208
pchMessageStart[2] = 0xb5;
207209
pchMessageStart[3] = 0xda;
208210
nMinerThreads = 1;
211+
nMaxTipAge = 24 * 60 * 60;
209212
genesis.nTime = 1296688602;
210213
genesis.nBits = 0x207fffff;
211214
genesis.nNonce = 2;

src/chainparams.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ class CChainParams
6060
bool DefaultConsistencyChecks() const { return fDefaultConsistencyChecks; }
6161
/** Policy: Filter transactions that do not match well-defined patterns */
6262
bool RequireStandard() const { return fRequireStandard; }
63+
int64_t MaxTipAge() const { return nMaxTipAge; }
6364
int64_t PruneAfterHeight() const { return nPruneAfterHeight; }
6465
/** Make miner stop after a block is found. In RPC, don't return until nGenProcLimit blocks are generated */
6566
bool MineBlocksOnDemand() const { return fMineBlocksOnDemand; }
@@ -80,6 +81,7 @@ class CChainParams
8081
std::vector<unsigned char> vAlertPubKey;
8182
int nDefaultPort;
8283
int nMinerThreads;
84+
long nMaxTipAge;
8385
uint64_t nPruneAfterHeight;
8486
std::vector<CDNSSeedData> vSeeds;
8587
std::vector<unsigned char> base58Prefixes[MAX_BASE58_TYPES];

src/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1239,7 +1239,7 @@ bool IsInitialBlockDownload()
12391239
if (lockIBDState)
12401240
return false;
12411241
bool state = (chainActive.Height() < pindexBestHeader->nHeight - 24 * 6 ||
1242-
pindexBestHeader->GetBlockTime() < GetTime() - 24 * 60 * 60);
1242+
pindexBestHeader->GetBlockTime() < GetTime() - chainParams.MaxTipAge());
12431243
if (!state)
12441244
lockIBDState = true;
12451245
return state;

0 commit comments

Comments
 (0)