Skip to content

Commit 0343676

Browse files
committed
Call TransactionRemovedFromMempool in the CScheduler thread
This is both good practice (we want to move all such callbacks into a background thread eventually) and prevents a lock inversion when we go to use this in wallet (mempool.cs->cs_wallet and cs_wallet->mempool.cs would otherwise both be used).
1 parent a7d3936 commit 0343676

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/validationinterface.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,9 @@ void UnregisterAllValidationInterfaces() {
106106

107107
void CMainSignals::MempoolEntryRemoved(CTransactionRef ptx, MemPoolRemovalReason reason) {
108108
if (reason != MemPoolRemovalReason::BLOCK && reason != MemPoolRemovalReason::CONFLICT) {
109-
m_internals->TransactionRemovedFromMempool(ptx);
109+
m_internals->m_schedulerClient.AddToProcessQueue([ptx, this] {
110+
m_internals->TransactionRemovedFromMempool(ptx);
111+
});
110112
}
111113
}
112114

src/validationinterface.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ class CValidationInterface {
4545
* size limiting, reorg (changes in lock times/coinbase maturity), or
4646
* replacement. This does not include any transactions which are included
4747
* in BlockConnectedDisconnected either in block->vtx or in txnConflicted.
48+
*
49+
* Called on a background thread.
4850
*/
4951
virtual void TransactionRemovedFromMempool(const CTransactionRef &ptx) {}
5052
/**

0 commit comments

Comments
 (0)