Skip to content

Commit f0f4904

Browse files
committed
Merge pull request bitcoin#4258
7b45d94 Make max number of orphan blocks kept in memory a startup parameter (fixes bitcoin#4253) (shshshsh)
2 parents d24310d + 7b45d94 commit f0f4904

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

src/init.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ std::string HelpMessage(HelpMessageMode hmm)
206206
strUsage += " -dbcache=<n> " + strprintf(_("Set database cache size in megabytes (%d to %d, default: %d)"), nMinDbCache, nMaxDbCache, nDefaultDbCache) + "\n";
207207
strUsage += " -keypool=<n> " + _("Set key pool size to <n> (default: 100)") + "\n";
208208
strUsage += " -loadblock=<file> " + _("Imports blocks from external blk000??.dat file") + " " + _("on startup") + "\n";
209+
strUsage += " -maxorphanblocks=<n> " + strprintf(_("Keep at most <n> unconnectable blocks in memory (default: %u)"), DEFAULT_MAX_ORPHAN_BLOCKS) + "\n";
209210
strUsage += " -par=<n> " + strprintf(_("Set the number of script verification threads (%u to %d, 0 = auto, <0 = leave that many cores free, default: %d)"), -(int)boost::thread::hardware_concurrency(), MAX_SCRIPTCHECK_THREADS, DEFAULT_SCRIPTCHECK_THREADS) + "\n";
210211
strUsage += " -pid=<file> " + _("Specify pid file (default: bitcoind.pid)") + "\n";
211212
strUsage += " -reindex " + _("Rebuild block chain index from current blk000??.dat files") + " " + _("on startup") + "\n";

src/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1160,7 +1160,7 @@ uint256 static GetOrphanRoot(const uint256& hash)
11601160
// Remove a random orphan block (which does not have any dependent orphans).
11611161
void static PruneOrphanBlocks()
11621162
{
1163-
if (mapOrphanBlocksByPrev.size() <= MAX_ORPHAN_BLOCKS)
1163+
if (mapOrphanBlocksByPrev.size() <= (size_t)std::max((int64_t)0, GetArg("-maxorphanblocks", DEFAULT_MAX_ORPHAN_BLOCKS)))
11641164
return;
11651165

11661166
// Pick a random orphan block.

src/main.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ static const unsigned int MAX_STANDARD_TX_SIZE = 100000;
4545
static const unsigned int MAX_BLOCK_SIGOPS = MAX_BLOCK_SIZE/50;
4646
/** The maximum number of orphan transactions kept in memory */
4747
static const unsigned int MAX_ORPHAN_TRANSACTIONS = MAX_BLOCK_SIZE/100;
48-
/** The maximum number of orphan blocks kept in memory */
49-
static const unsigned int MAX_ORPHAN_BLOCKS = 750;
48+
/** Default for -maxorphanblocks, maximum number of orphan blocks kept in memory */
49+
static const unsigned int DEFAULT_MAX_ORPHAN_BLOCKS = 750;
5050
/** The maximum size of a blk?????.dat file (since 0.8) */
5151
static const unsigned int MAX_BLOCKFILE_SIZE = 0x8000000; // 128 MiB
5252
/** The pre-allocation chunk size for blk?????.dat files (since 0.8) */

0 commit comments

Comments
 (0)