reduce number of lookups in TransactionWithinChainLimit
This commit is contained in:
parent
af9bedbff6
commit
cee16123f5
1 changed files with 3 additions and 3 deletions
|
@ -1145,7 +1145,7 @@ void CTxMemPool::TrimToSize(size_t sizelimit, std::vector<uint256>* pvNoSpendsRe
|
||||||
|
|
||||||
bool CTxMemPool::TransactionWithinChainLimit(const uint256& txid, size_t chainLimit) const {
|
bool CTxMemPool::TransactionWithinChainLimit(const uint256& txid, size_t chainLimit) const {
|
||||||
LOCK(cs);
|
LOCK(cs);
|
||||||
if (exists(txid) && std::max(mapTx.find(txid)->GetCountWithAncestors(), mapTx.find(txid)->GetCountWithDescendants()) >= chainLimit)
|
auto it = mapTx.find(txid);
|
||||||
return false;
|
return it == mapTx.end() || (it->GetCountWithAncestors() < chainLimit &&
|
||||||
return true;
|
it->GetCountWithDescendants() < chainLimit);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue