aboutsummaryrefslogtreecommitdiff
path: root/src/txmempool.cpp
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2015-10-07 23:34:55 +0200
committerPieter Wuille <pieter.wuille@gmail.com>2015-10-20 18:59:08 +0200
commitab1f56072a796b0ff039d6690c6ac929dbcbf243 (patch)
treebd16f4d42d3a075a41879dbaef2674a25a7442e2 /src/txmempool.cpp
parentc6de5cc88614f587ae2d0e360536412407e02836 (diff)
downloadbitcoin-ab1f56072a796b0ff039d6690c6ac929dbcbf243.tar.xz
Support -checkmempool=N, which runs checks on average once every N transactions
Diffstat (limited to 'src/txmempool.cpp')
-rw-r--r--src/txmempool.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/txmempool.cpp b/src/txmempool.cpp
index 1370cab0c0..c379a45b48 100644
--- a/src/txmempool.cpp
+++ b/src/txmempool.cpp
@@ -311,7 +311,7 @@ CTxMemPool::CTxMemPool(const CFeeRate& _minRelayFee) :
// Sanity checks off by default for performance, because otherwise
// accepting transactions becomes O(N^2) where N is the number
// of transactions in the pool
- fSanityCheck = false;
+ nCheckFrequency = 0;
minerPolicyEstimator = new CBlockPolicyEstimator(_minRelayFee);
}
@@ -483,7 +483,7 @@ void CTxMemPool::removeCoinbaseSpends(const CCoinsViewCache *pcoins, unsigned in
if (it2 != mapTx.end())
continue;
const CCoins *coins = pcoins->AccessCoins(txin.prevout.hash);
- if (fSanityCheck) assert(coins);
+ if (nCheckFrequency != 0) assert(coins);
if (!coins || (coins->IsCoinBase() && ((signed long)nMemPoolHeight) - coins->nHeight < COINBASE_MATURITY)) {
transactionsToRemove.push_back(tx);
break;
@@ -553,7 +553,10 @@ void CTxMemPool::clear()
void CTxMemPool::check(const CCoinsViewCache *pcoins) const
{
- if (!fSanityCheck)
+ if (nCheckFrequency == 0)
+ return;
+
+ if (insecure_rand() >= nCheckFrequency)
return;
LogPrint("mempool", "Checking mempool with %u transactions and %u inputs\n", (unsigned int)mapTx.size(), (unsigned int)mapNextTx.size());