From 94cf9e41d5da69f17c6897317f48292afd3bc28c Mon Sep 17 00:00:00 2001 From: michilumin Date: Sat, 27 Sep 2014 14:30:53 -0600 Subject: [PATCH 1/4] Initial check in of branch for conflict resolution --- src/init.cpp | 2 ++ src/main.cpp | 3 ++- src/main.h | 5 +++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/init.cpp b/src/init.cpp index 2d1578e98..81c035327 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -211,6 +211,8 @@ std::string HelpMessage(HelpMessageMode hmm) strUsage += " -dbcache= " + strprintf(_("Set database cache size in megabytes (%d to %d, default: %d)"), nMinDbCache, nMaxDbCache, nDefaultDbCache) + "\n"; strUsage += " -keypool= " + _("Set key pool size to (default: 100)") + "\n"; strUsage += " -loadblock= " + _("Imports blocks from external blk000??.dat file") + " " + _("on startup") + "\n"; + strUsage += " -maxorphanblocks= " + strprintf(_("Keep at most unconnectable blocks in memory (default: %u)"), DEFAULT_MAX_ORPHAN_BLOCKS) + "\n"; + strUsage += " -maxorphantx= " + strprintf(_("Keep at most unconnectable transactions in memory (default: %u)"), DEFAULT_MAX_ORPHAN_TRANSACTIONS) + "\n"; strUsage += " -par= " + 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= " + _("Specify pid file (default: dogecoind.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 f6e709365..b9ca00d71 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4116,7 +4116,8 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) AddOrphanTx(tx); // 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); } diff --git a/src/main.h b/src/main.h index a0ba6e913..0edf0a144 100644 --- a/src/main.h +++ b/src/main.h @@ -48,10 +48,15 @@ static const unsigned int DEFAULT_BLOCK_PRIORITY_SIZE = 17000; static const unsigned int MAX_STANDARD_TX_SIZE = 100000; /** The maximum allowed number of signature check operations in a block (network rule) */ static const unsigned int MAX_BLOCK_SIGOPS = MAX_BLOCK_SIZE/50; +<<<<<<< HEAD /** 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 -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) */ static const unsigned int MAX_BLOCKFILE_SIZE = 0x8000000; // 128 MiB /** The pre-allocation chunk size for blk?????.dat files (since 0.8) */ From 8a88bb6550eb3b9477d58cc58624231624ef4b50 Mon Sep 17 00:00:00 2001 From: Gavin Andresen Date: Wed, 10 Sep 2014 14:08:03 -0400 Subject: [PATCH 2/4] 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. Conflicts: src/main.h --- src/main.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main.h b/src/main.h index 0edf0a144..211d1b32f 100644 --- a/src/main.h +++ b/src/main.h @@ -48,7 +48,6 @@ static const unsigned int DEFAULT_BLOCK_PRIORITY_SIZE = 17000; static const unsigned int MAX_STANDARD_TX_SIZE = 100000; /** The maximum allowed number of signature check operations in a block (network rule) */ static const unsigned int MAX_BLOCK_SIGOPS = MAX_BLOCK_SIZE/50; -<<<<<<< HEAD /** 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 */ From 5cda7594f0a9cc2f343061128483f50810368cbd Mon Sep 17 00:00:00 2001 From: shshshsh Date: Fri, 30 May 2014 12:35:23 +0000 Subject: [PATCH 3/4] Make max number of orphan blocks kept in memory a startup parameter (fixes #4253) Rebased-From: 7b45d943b29a443f1ac808c9ee4eeed6df0db9cc Conflicts: src/init.cpp src/main.h --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index b9ca00d71..db9d4bf45 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1181,7 +1181,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.