Browse Source

reduce number of lookups in TransactionWithinChainLimit

0.14
Gregory Sanders 8 years ago
parent
commit
cee16123f5
  1. 6
      src/txmempool.cpp

6
src/txmempool.cpp

@ -1145,7 +1145,7 @@ void CTxMemPool::TrimToSize(size_t sizelimit, std::vector<uint256>* pvNoSpendsRe @@ -1145,7 +1145,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);
}

Loading…
Cancel
Save