aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2014-06-04 19:30:19 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2014-06-04 19:30:44 +0200
commitf0f4904becbf2514c7cdc53a8942faf3982dda19 (patch)
tree90a7f60820bcc1322bd0479be94c4cb2a09a580f
parentd24310d23aa323dea1c80be52395d6194ac18232 (diff)
parent7b45d943b29a443f1ac808c9ee4eeed6df0db9cc (diff)
Merge pull request #4258
7b45d94 Make max number of orphan blocks kept in memory a startup parameter (fixes #4253) (shshshsh)
-rw-r--r--src/init.cpp1
-rw-r--r--src/main.cpp2
-rw-r--r--src/main.h4
3 files changed, 4 insertions, 3 deletions
diff --git a/src/init.cpp b/src/init.cpp
index 840a07d610..3255f5bf10 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -206,6 +206,7 @@ std::string HelpMessage(HelpMessageMode hmm)
strUsage += " -dbcache=<n> " + strprintf(_("Set database cache size in megabytes (%d to %d, default: %d)"), nMinDbCache, nMaxDbCache, nDefaultDbCache) + "\n";
strUsage += " -keypool=<n> " + _("Set key pool size to <n> (default: 100)") + "\n";
strUsage += " -loadblock=<file> " + _("Imports blocks from external blk000??.dat file") + " " + _("on startup") + "\n";
+ strUsage += " -maxorphanblocks=<n> " + strprintf(_("Keep at most <n> unconnectable blocks in memory (default: %u)"), DEFAULT_MAX_ORPHAN_BLOCKS) + "\n";
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";
strUsage += " -pid=<file> " + _("Specify pid file (default: bitcoind.pid)") + "\n";
strUsage += " -reindex " + _("Rebuild block chain index from current blk000??.dat files") + " " + _("on startup") + "\n";
diff --git a/src/main.cpp b/src/main.cpp
index 30fa9c6d70..b1258839d0 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1160,7 +1160,7 @@ uint256 static GetOrphanRoot(const uint256& hash)
// Remove a random orphan block (which does not have any dependent orphans).
void static PruneOrphanBlocks()
{
- if (mapOrphanBlocksByPrev.size() <= MAX_ORPHAN_BLOCKS)
+ if (mapOrphanBlocksByPrev.size() <= (size_t)std::max((int64_t)0, GetArg("-maxorphanblocks", DEFAULT_MAX_ORPHAN_BLOCKS)))
return;
// Pick a random orphan block.
diff --git a/src/main.h b/src/main.h
index 42cf4a0861..3fccd32a29 100644
--- a/src/main.h
+++ b/src/main.h
@@ -45,8 +45,8 @@ static const unsigned int MAX_STANDARD_TX_SIZE = 100000;
static const unsigned int MAX_BLOCK_SIGOPS = MAX_BLOCK_SIZE/50;
/** The maximum number of orphan transactions kept in memory */
static const unsigned int MAX_ORPHAN_TRANSACTIONS = MAX_BLOCK_SIZE/100;
-/** The maximum number of orphan blocks kept in memory */
-static const unsigned int MAX_ORPHAN_BLOCKS = 750;
+/** Default for -maxorphanblocks, maximum number of orphan blocks kept in memory */
+static const unsigned int DEFAULT_MAX_ORPHAN_BLOCKS = 750;
/** The maximum size of a blk?????.dat file (since 0.8) */
static const unsigned int MAX_BLOCKFILE_SIZE = 0x8000000; // 128 MiB
/** The pre-allocation chunk size for blk?????.dat files (since 0.8) */