Skip to content

Commit cee1612

Browse files
committed
reduce number of lookups in TransactionWithinChainLimit
1 parent af9bedb commit cee1612

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/txmempool.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1145,7 +1145,7 @@ void CTxMemPool::TrimToSize(size_t sizelimit, std::vector<uint256>* pvNoSpendsRe
11451145

11461146
bool CTxMemPool::TransactionWithinChainLimit(const uint256& txid, size_t chainLimit) const {
11471147
LOCK(cs);
1148-
if (exists(txid) && std::max(mapTx.find(txid)->GetCountWithAncestors(), mapTx.find(txid)->GetCountWithDescendants()) >= chainLimit)
1149-
return false;
1150-
return true;
1148+
auto it = mapTx.find(txid);
1149+
return it == mapTx.end() || (it->GetCountWithAncestors() < chainLimit &&
1150+
it->GetCountWithDescendants() < chainLimit);
11511151
}

0 commit comments

Comments
 (0)