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) {
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
* replacement. This does not include any transactions which are included
* in BlockConnectedDisconnected either in block->vtx or in txnConflicted.
*
* Called on a background thread.
*/
virtual void TransactionRemovedFromMempool(const CTransactionRef &ptx) {}
/**