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).
This commit is contained in:
Matt Corallo 2017-06-08 11:05:18 -04:00
parent a7d3936de8
commit 0343676ce3
2 changed files with 5 additions and 1 deletions

View file

@ -106,7 +106,9 @@ void UnregisterAllValidationInterfaces() {
void CMainSignals::MempoolEntryRemoved(CTransactionRef ptx, MemPoolRemovalReason reason) { void CMainSignals::MempoolEntryRemoved(CTransactionRef ptx, MemPoolRemovalReason reason) {
if (reason != MemPoolRemovalReason::BLOCK && reason != MemPoolRemovalReason::CONFLICT) { if (reason != MemPoolRemovalReason::BLOCK && reason != MemPoolRemovalReason::CONFLICT) {
m_internals->TransactionRemovedFromMempool(ptx); m_internals->m_schedulerClient.AddToProcessQueue([ptx, this] {
m_internals->TransactionRemovedFromMempool(ptx);
});
} }
} }

View file

@ -45,6 +45,8 @@ protected:
* size limiting, reorg (changes in lock times/coinbase maturity), or * size limiting, reorg (changes in lock times/coinbase maturity), or
* replacement. This does not include any transactions which are included * replacement. This does not include any transactions which are included
* in BlockConnectedDisconnected either in block->vtx or in txnConflicted. * in BlockConnectedDisconnected either in block->vtx or in txnConflicted.
*
* Called on a background thread.
*/ */
virtual void TransactionRemovedFromMempool(const CTransactionRef &ptx) {} virtual void TransactionRemovedFromMempool(const CTransactionRef &ptx) {}
/** /**