Skip to content

Commit e1ff0db

Browse files
instagibbsbtcdrak
authored andcommitted
reduce number of lookups in TransactionWithinChainLimit
1 parent 4bf2bec commit e1ff0db

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
@@ -1137,7 +1137,7 @@ void CTxMemPool::TrimToSize(size_t sizelimit, std::vector<uint256>* pvNoSpendsRe
11371137

11381138
bool CTxMemPool::TransactionWithinChainLimit(const uint256& txid, size_t chainLimit) const {
11391139
LOCK(cs);
1140-
if (exists(txid) && std::max(mapTx.find(txid)->GetCountWithAncestors(), mapTx.find(txid)->GetCountWithDescendants()) >= chainLimit)
1141-
return false;
1142-
return true;
1140+
auto it = mapTx.find(txid);
1141+
return it == mapTx.end() || (it->GetCountWithAncestors() < chainLimit &&
1142+
it->GetCountWithDescendants() < chainLimit);
11431143
}

0 commit comments

Comments
 (0)