aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.cpp28
-rw-r--r--src/main.h2
-rw-r--r--src/rpcblockchain.cpp4
-rw-r--r--src/rpcnet.cpp2
-rw-r--r--src/rpcwallet.cpp4
5 files changed, 34 insertions, 6 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 4532b776c6..d33ad2fa95 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1054,6 +1054,31 @@ uint256 static GetOrphanRoot(const uint256& hash)
} while(true);
}
+// Remove a random orphan block (which does not have any dependent orphans).
+void static PruneOrphanBlocks()
+{
+ if (mapOrphanBlocksByPrev.size() <= MAX_ORPHAN_BLOCKS)
+ return;
+
+ // Pick a random orphan block.
+ int pos = insecure_rand() % mapOrphanBlocksByPrev.size();
+ std::multimap<uint256, COrphanBlock*>::iterator it = mapOrphanBlocksByPrev.begin();
+ while (pos--) it++;
+
+ // As long as this block has other orphans depending on it, move to one of those successors.
+ do {
+ std::multimap<uint256, COrphanBlock*>::iterator it2 = mapOrphanBlocksByPrev.find(it->second->hashBlock);
+ if (it2 == mapOrphanBlocksByPrev.end())
+ break;
+ it = it2;
+ } while(1);
+
+ uint256 hash = it->second->hashBlock;
+ delete it->second;
+ mapOrphanBlocksByPrev.erase(it);
+ mapOrphanBlocks.erase(hash);
+}
+
int64_t GetBlockValue(int nHeight, int64_t nFees)
{
int64_t nSubsidy = 50 * COIN;
@@ -2373,10 +2398,11 @@ bool ProcessBlock(CValidationState &state, CNode* pfrom, CBlock* pblock, CDiskBl
// If we don't already have its previous block, shunt it off to holding area until we get it
if (pblock->hashPrevBlock != 0 && !mapBlockIndex.count(pblock->hashPrevBlock))
{
- LogPrintf("ProcessBlock: ORPHAN BLOCK, prev=%s\n", pblock->hashPrevBlock.ToString());
+ LogPrintf("ProcessBlock: ORPHAN BLOCK %lu, prev=%s\n", (unsigned long)mapOrphanBlocks.size(), pblock->hashPrevBlock.ToString());
// Accept orphans as long as there is a node to request its parents from
if (pfrom) {
+ PruneOrphanBlocks();
COrphanBlock* pblock2 = new COrphanBlock();
{
CDataStream ss(SER_DISK, CLIENT_VERSION);
diff --git a/src/main.h b/src/main.h
index bbf6fce48b..05210e5164 100644
--- a/src/main.h
+++ b/src/main.h
@@ -45,6 +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;
/** 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) */
diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp
index 661deffb19..78a92ce1e9 100644
--- a/src/rpcblockchain.cpp
+++ b/src/rpcblockchain.cpp
@@ -410,8 +410,8 @@ Value verifychain(const Array& params, bool fHelp)
"verifychain ( checklevel numblocks )\n"
"\nVerifies blockchain database.\n"
"\nArguments:\n"
- "1. checklevel (numeric, optional, default=3) The level\n"
- "2. numblocks (numeric, optional, 288) The number of blocks\n"
+ "1. checklevel (numeric, optional, 0-4, default=3) How thorough the block verification is.\n"
+ "2. numblocks (numeric, optional, default=288, 0=all) The number of blocks to check.\n"
"\nResult:\n"
"true|false (boolean) Verified or not\n"
"\nExamples:\n"
diff --git a/src/rpcnet.cpp b/src/rpcnet.cpp
index a3b37aa9e5..d9bcc3429d 100644
--- a/src/rpcnet.cpp
+++ b/src/rpcnet.cpp
@@ -47,7 +47,7 @@ Value ping(const Array& params, bool fHelp)
"ping\n"
"\nRequests that a ping be sent to all other nodes, to measure ping time.\n"
"Results provided in getpeerinfo, pingtime and pingwait fields are decimal seconds.\n"
- "Ping command is handled in queue with all other commands, so it measures processing backlog, not just network ping."
+ "Ping command is handled in queue with all other commands, so it measures processing backlog, not just network ping.\n"
"\nExamples:\n"
+ HelpExampleCli("ping", "")
+ HelpExampleRpc("ping", "")
diff --git a/src/rpcwallet.cpp b/src/rpcwallet.cpp
index 8311b39c4e..7045225825 100644
--- a/src/rpcwallet.cpp
+++ b/src/rpcwallet.cpp
@@ -1850,9 +1850,9 @@ Value settxfee(const Array& params, bool fHelp)
if (fHelp || params.size() < 1 || params.size() > 1)
throw runtime_error(
"settxfee amount\n"
- "\nSet the transaction fee per KB.\n"
+ "\nSet the transaction fee per kB.\n"
"\nArguments:\n"
- "1. amount (numeric, required) The transaction fee in BTC/KB rounded to the nearest 0.00000001\n"
+ "1. amount (numeric, required) The transaction fee in BTC/kB rounded to the nearest 0.00000001\n"
"\nResult\n"
"true|false (boolean) Returns true if successful\n"
"\nExamples:\n"