diff --git a/src/net_processing.cpp b/src/net_processing.cpp index 57e6fc7b2fa..6cf76d3f42d 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -3150,17 +3150,7 @@ void PeerManagerImpl::ProcessValidTx(NodeId nodeid, const CTransactionRef& tx, c AssertLockHeld(g_msgproc_mutex); AssertLockHeld(m_tx_download_mutex); - auto& m_orphanage = m_txdownloadman.GetOrphanageRef(); - auto& m_txrequest = m_txdownloadman.GetTxRequestRef(); - - // As this version of the transaction was acceptable, we can forget about any requests for it. - // No-op if the tx is not in txrequest. - m_txrequest.ForgetTxHash(tx->GetHash()); - m_txrequest.ForgetTxHash(tx->GetWitnessHash()); - - m_orphanage.AddChildrenToWorkSet(*tx); - // If it came from the orphanage, remove it. No-op if the tx is not in txorphanage. - m_orphanage.EraseTx(tx->GetWitnessHash()); + m_txdownloadman.MempoolAcceptedTx(tx); LogDebug(BCLog::MEMPOOL, "AcceptToMemoryPool: peer=%d: accepted %s (wtxid=%s) (poolsz %u txn, %u kB)\n", nodeid, diff --git a/src/node/txdownloadman.h b/src/node/txdownloadman.h index 1a1f0a6da71..4c2e35e23ac 100644 --- a/src/node/txdownloadman.h +++ b/src/node/txdownloadman.h @@ -152,6 +152,9 @@ public: * skipping any combinations that have already been tried. Return the resulting package along with * the senders of its respective transactions, or std::nullopt if no package is found. */ std::optional Find1P1CPackage(const CTransactionRef& ptx, NodeId nodeid); + + /** Respond to successful transaction submission to mempool */ + void MempoolAcceptedTx(const CTransactionRef& tx); }; } // namespace node #endif // BITCOIN_NODE_TXDOWNLOADMAN_H diff --git a/src/node/txdownloadman_impl.cpp b/src/node/txdownloadman_impl.cpp index 2a62b090c00..1a8de26983f 100644 --- a/src/node/txdownloadman_impl.cpp +++ b/src/node/txdownloadman_impl.cpp @@ -75,6 +75,10 @@ std::optional TxDownloadManager::Find1P1CPackage(const CTrans { return m_impl->Find1P1CPackage(ptx, nodeid); } +void TxDownloadManager::MempoolAcceptedTx(const CTransactionRef& tx) +{ + m_impl->MempoolAcceptedTx(tx); +} // TxDownloadManagerImpl void TxDownloadManagerImpl::ActiveTipChange() @@ -272,4 +276,16 @@ std::optional TxDownloadManagerImpl::Find1P1CPackage(const CT } return std::nullopt; } + +void TxDownloadManagerImpl::MempoolAcceptedTx(const CTransactionRef& tx) +{ + // As this version of the transaction was acceptable, we can forget about any requests for it. + // No-op if the tx is not in txrequest. + m_txrequest.ForgetTxHash(tx->GetHash()); + m_txrequest.ForgetTxHash(tx->GetWitnessHash()); + + m_orphanage.AddChildrenToWorkSet(*tx); + // If it came from the orphanage, remove it. No-op if the tx is not in txorphanage. + m_orphanage.EraseTx(tx->GetWitnessHash()); +} } // namespace node diff --git a/src/node/txdownloadman_impl.h b/src/node/txdownloadman_impl.h index 730a9642ad8..b9a89f1f63d 100644 --- a/src/node/txdownloadman_impl.h +++ b/src/node/txdownloadman_impl.h @@ -162,6 +162,8 @@ public: void ReceivedNotFound(NodeId nodeid, const std::vector& txhashes); std::optional Find1P1CPackage(const CTransactionRef& ptx, NodeId nodeid); + + void MempoolAcceptedTx(const CTransactionRef& tx); }; } // namespace node #endif // BITCOIN_NODE_TXDOWNLOADMAN_IMPL_H