diff options
author | Pieter Wuille <pieter.wuille@gmail.com> | 2015-10-28 02:24:44 +0100 |
---|---|---|
committer | Pieter Wuille <pieter.wuille@gmail.com> | 2015-10-28 02:25:06 +0100 |
commit | e06c14fb59ee493da5283819420d949a14304ca7 (patch) | |
tree | 2d1b41bd1895a3e59001f44b6eda249bdf5c2712 /src/txmempool.cpp | |
parent | 8756c986420ccd8302c396e0db8f5434dd41c57a (diff) | |
parent | ab1f56072a796b0ff039d6690c6ac929dbcbf243 (diff) |
Merge pull request #6776
ab1f560 Support -checkmempool=N, which runs checks on average once every N transactions (Pieter Wuille)
Diffstat (limited to 'src/txmempool.cpp')
-rw-r--r-- | src/txmempool.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/txmempool.cpp b/src/txmempool.cpp index 47e8de5361..a772e7adea 100644 --- a/src/txmempool.cpp +++ b/src/txmempool.cpp @@ -314,7 +314,7 @@ CTxMemPool::CTxMemPool(const CFeeRate& _minReasonableRelayFee) : // 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(_minReasonableRelayFee); minReasonableRelayFee = _minReasonableRelayFee; @@ -487,7 +487,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; @@ -568,7 +568,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()); |