Skip to content

Commit c6b2174

Browse files
committed
[refactor] move valid tx processing to TxDownload
1 parent a8cf3b6 commit c6b2174

File tree

4 files changed

+22
-11
lines changed

4 files changed

+22
-11
lines changed

src/net_processing.cpp

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3150,17 +3150,7 @@ void PeerManagerImpl::ProcessValidTx(NodeId nodeid, const CTransactionRef& tx, c
31503150
AssertLockHeld(g_msgproc_mutex);
31513151
AssertLockHeld(m_tx_download_mutex);
31523152

3153-
auto& m_orphanage = m_txdownloadman.GetOrphanageRef();
3154-
auto& m_txrequest = m_txdownloadman.GetTxRequestRef();
3155-
3156-
// As this version of the transaction was acceptable, we can forget about any requests for it.
3157-
// No-op if the tx is not in txrequest.
3158-
m_txrequest.ForgetTxHash(tx->GetHash());
3159-
m_txrequest.ForgetTxHash(tx->GetWitnessHash());
3160-
3161-
m_orphanage.AddChildrenToWorkSet(*tx);
3162-
// If it came from the orphanage, remove it. No-op if the tx is not in txorphanage.
3163-
m_orphanage.EraseTx(tx->GetWitnessHash());
3153+
m_txdownloadman.MempoolAcceptedTx(tx);
31643154

31653155
LogDebug(BCLog::MEMPOOL, "AcceptToMemoryPool: peer=%d: accepted %s (wtxid=%s) (poolsz %u txn, %u kB)\n",
31663156
nodeid,

src/node/txdownloadman.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,9 @@ class TxDownloadManager {
152152
* skipping any combinations that have already been tried. Return the resulting package along with
153153
* the senders of its respective transactions, or std::nullopt if no package is found. */
154154
std::optional<PackageToValidate> Find1P1CPackage(const CTransactionRef& ptx, NodeId nodeid);
155+
156+
/** Respond to successful transaction submission to mempool */
157+
void MempoolAcceptedTx(const CTransactionRef& tx);
155158
};
156159
} // namespace node
157160
#endif // BITCOIN_NODE_TXDOWNLOADMAN_H

src/node/txdownloadman_impl.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ std::optional<PackageToValidate> TxDownloadManager::Find1P1CPackage(const CTrans
7575
{
7676
return m_impl->Find1P1CPackage(ptx, nodeid);
7777
}
78+
void TxDownloadManager::MempoolAcceptedTx(const CTransactionRef& tx)
79+
{
80+
m_impl->MempoolAcceptedTx(tx);
81+
}
7882

7983
// TxDownloadManagerImpl
8084
void TxDownloadManagerImpl::ActiveTipChange()
@@ -272,4 +276,16 @@ std::optional<PackageToValidate> TxDownloadManagerImpl::Find1P1CPackage(const CT
272276
}
273277
return std::nullopt;
274278
}
279+
280+
void TxDownloadManagerImpl::MempoolAcceptedTx(const CTransactionRef& tx)
281+
{
282+
// As this version of the transaction was acceptable, we can forget about any requests for it.
283+
// No-op if the tx is not in txrequest.
284+
m_txrequest.ForgetTxHash(tx->GetHash());
285+
m_txrequest.ForgetTxHash(tx->GetWitnessHash());
286+
287+
m_orphanage.AddChildrenToWorkSet(*tx);
288+
// If it came from the orphanage, remove it. No-op if the tx is not in txorphanage.
289+
m_orphanage.EraseTx(tx->GetWitnessHash());
290+
}
275291
} // namespace node

src/node/txdownloadman_impl.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,8 @@ class TxDownloadManagerImpl {
162162
void ReceivedNotFound(NodeId nodeid, const std::vector<uint256>& txhashes);
163163

164164
std::optional<PackageToValidate> Find1P1CPackage(const CTransactionRef& ptx, NodeId nodeid);
165+
166+
void MempoolAcceptedTx(const CTransactionRef& tx);
165167
};
166168
} // namespace node
167169
#endif // BITCOIN_NODE_TXDOWNLOADMAN_IMPL_H

0 commit comments

Comments
 (0)