aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGavin Andresen <gavinandresen@gmail.com>2014-09-10 14:08:03 -0400
committerGavin Andresen <gavinandresen@gmail.com>2014-09-10 14:09:40 -0400
commitaa3c697e90c02d5797a59a7bfb1ecac6fbd918cf (patch)
treec98a1175ece5c99f28f45642d3109d9877bd7b35 /src
parentc74332c67806ed92e6e18de174671a7c30608780 (diff)
downloadbitcoin-aa3c697e90c02d5797a59a7bfb1ecac6fbd918cf.tar.xz
Store fewer orphan tx by default, add -maxorphantx option
There is no reason to store thousands of orphan transactions; normally an orphan's parents will either be broadcast or mined reasonably quickly. This pull drops the maximum number of orphans from 10,000 down to 100, and adds a command-line option (-maxorphantx) that is just like -maxorphanblocks to override the default.
Diffstat (limited to 'src')
-rw-r--r--src/init.cpp1
-rw-r--r--src/main.cpp3
-rw-r--r--src/main.h4
3 files changed, 5 insertions, 3 deletions
diff --git a/src/init.cpp b/src/init.cpp
index 31f64878fb..8f336c31fb 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -226,6 +226,7 @@ std::string HelpMessage(HelpMessageMode mode)
strUsage += " -dbcache=<n> " + strprintf(_("Set database cache size in megabytes (%d to %d, default: %d)"), nMinDbCache, nMaxDbCache, nDefaultDbCache) + "\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 += " -maxorphantx=<n> " + strprintf(_("Keep at most <n> unconnectable transactions in memory (default: %u)"), DEFAULT_MAX_ORPHAN_TRANSACTIONS) + "\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 6a2e6ac659..f978254961 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -3856,7 +3856,8 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
AddOrphanTx(tx, pfrom->GetId());
// DoS prevention: do not allow mapOrphanTransactions to grow unbounded
- unsigned int nEvicted = LimitOrphanTxSize(MAX_ORPHAN_TRANSACTIONS);
+ unsigned int nMaxOrphanTx = (unsigned int)std::max((int64_t)0, GetArg("-maxorphantx", DEFAULT_MAX_ORPHAN_TRANSACTIONS));
+ unsigned int nEvicted = LimitOrphanTxSize(nMaxOrphanTx);
if (nEvicted > 0)
LogPrint("mempool", "mapOrphan overflow, removed %u tx\n", nEvicted);
} else if (pfrom->fWhitelisted) {
diff --git a/src/main.h b/src/main.h
index 30cccab2f1..d340fd0b6a 100644
--- a/src/main.h
+++ b/src/main.h
@@ -51,8 +51,8 @@ static const unsigned int MAX_BLOCK_SIGOPS = MAX_BLOCK_SIZE/50;
static const unsigned int MAX_P2SH_SIGOPS = 15;
/** The maximum number of sigops we're willing to relay/mine in a single tx */
static const unsigned int MAX_TX_SIGOPS = MAX_BLOCK_SIGOPS/5;
-/** The maximum number of orphan transactions kept in memory */
-static const unsigned int MAX_ORPHAN_TRANSACTIONS = MAX_BLOCK_SIZE/100;
+/** Default for -maxorphantx, maximum number of orphan transactions kept in memory */
+static const unsigned int DEFAULT_MAX_ORPHAN_TRANSACTIONS = 100;
/** 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) */