Merge bitcoin/bitcoin#33946: interfaces: remove redundant mempool lock in ChainImpl::isInMempool()
2909655fbafix: 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 ACK2909655fbainstagibbs: utACK2909655fbastickies-v: ACK2909655fbaTree-SHA512: 4dfd88e01d8c7a4b6ceb3c736243fb22bfee5ccfc422d134acb633b908ca14c807637a2aa20de89e86e583b23ec70a1d121d77e35af60e114d93971b2a4bfd3b
This commit is contained in:
1 file changed
-1
@@ -658,7 +658,6 @@ public:
|
|||||||
bool isInMempool(const Txid& txid) override
|
bool isInMempool(const Txid& txid) override
|
||||||
{
|
{
|
||||||
if (!m_node.mempool) return false;
|
if (!m_node.mempool) return false;
|
||||||
LOCK(m_node.mempool->cs);
|
|
||||||
return m_node.mempool->exists(txid);
|
return m_node.mempool->exists(txid);
|
||||||
}
|
}
|
||||||
bool hasDescendantsInMempool(const Txid& txid) override
|
bool hasDescendantsInMempool(const Txid& txid) override
|
||||||
|
|||||||
Reference in new issue
Block a user