aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory Sanders <gsanders87@gmail.com>2016-12-19 09:35:23 -0500
committerBtcDrak <btcdrak@gmail.com>2016-12-20 10:10:32 +0000
commite1ff0dbe19c3e7df21206d22bb12c686cd130b4c (patch)
treede6b339828d676de15ca1b05b8bee3bf8b087a46
parent4bf2bec18e5f3c613a0bf5c5fa78f6ec14dcc4f5 (diff)
reduce number of lookups in TransactionWithinChainLimit
-rw-r--r--src/txmempool.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/txmempool.cpp b/src/txmempool.cpp
index a7056554ad..63a26da326 100644
--- a/src/txmempool.cpp
+++ b/src/txmempool.cpp
@@ -1137,7 +1137,7 @@ void CTxMemPool::TrimToSize(size_t sizelimit, std::vector<uint256>* pvNoSpendsRe
bool CTxMemPool::TransactionWithinChainLimit(const uint256& txid, size_t chainLimit) const {
LOCK(cs);
- if (exists(txid) && std::max(mapTx.find(txid)->GetCountWithAncestors(), mapTx.find(txid)->GetCountWithDescendants()) >= chainLimit)
- return false;
- return true;
+ auto it = mapTx.find(txid);
+ return it == mapTx.end() || (it->GetCountWithAncestors() < chainLimit &&
+ it->GetCountWithDescendants() < chainLimit);
}