mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-31 18:51:12 +00:00
Merge bitcoin/bitcoin#33946: interfaces: remove redundant mempool lock in ChainImpl::isInMempool()
2909655fba91a7cc59c484fc74afafdf7ccc0cfa fix: remove redundant mempool lock in ChainImpl::isInMempool() (Fibonacci747)
Pull request description:
This PR removes an unnecessary `LOCK(mempool->cs)` in `ChainImpl::isInMempool()`. The method calls `CTxMemPool::exists()`, which already locks `mempool->cs` internally. Because the mempool mutex is a RecursiveMutex, double-locking was safe but redundant. Dropping the outer lock matches patterns used elsewhere in ChainImpl (e.g. `hasDescendantsInMempool()` and `GetTransactionAncestry()` callers) where mempool read APIs are invoked without an additional lock and rely on the callee’s internal locking. `isRBFOptIn()` remains unchanged since `IsRBFOptIn(tx, pool)` explicitly requires the caller to hold `pool.cs` as indicated by its thread-safety annotation.
ACKs for top commit:
maflcko:
lgtm ACK 2909655fba91a7cc59c484fc74afafdf7ccc0cfa
instagibbs:
utACK 2909655fba91a7cc59c484fc74afafdf7ccc0cfa
stickies-v:
ACK 2909655fba91a7cc59c484fc74afafdf7ccc0cfa
Tree-SHA512: 4dfd88e01d8c7a4b6ceb3c736243fb22bfee5ccfc422d134acb633b908ca14c807637a2aa20de89e86e583b23ec70a1d121d77e35af60e114d93971b2a4bfd3b
This commit is contained in:
commit
85d058dc53
@ -658,7 +658,6 @@ public:
|
||||
bool isInMempool(const Txid& txid) override
|
||||
{
|
||||
if (!m_node.mempool) return false;
|
||||
LOCK(m_node.mempool->cs);
|
||||
return m_node.mempool->exists(txid);
|
||||
}
|
||||
bool hasDescendantsInMempool(const Txid& txid) override
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user