mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-29 14:59:39 -04:00
[refactor] move valid tx processing to TxDownload
This commit is contained in:
parent
a8cf3b6e84
commit
c6b21749ca
4 changed files with 22 additions and 11 deletions
|
@ -3150,17 +3150,7 @@ void PeerManagerImpl::ProcessValidTx(NodeId nodeid, const CTransactionRef& tx, c
|
||||||
AssertLockHeld(g_msgproc_mutex);
|
AssertLockHeld(g_msgproc_mutex);
|
||||||
AssertLockHeld(m_tx_download_mutex);
|
AssertLockHeld(m_tx_download_mutex);
|
||||||
|
|
||||||
auto& m_orphanage = m_txdownloadman.GetOrphanageRef();
|
m_txdownloadman.MempoolAcceptedTx(tx);
|
||||||
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());
|
|
||||||
|
|
||||||
LogDebug(BCLog::MEMPOOL, "AcceptToMemoryPool: peer=%d: accepted %s (wtxid=%s) (poolsz %u txn, %u kB)\n",
|
LogDebug(BCLog::MEMPOOL, "AcceptToMemoryPool: peer=%d: accepted %s (wtxid=%s) (poolsz %u txn, %u kB)\n",
|
||||||
nodeid,
|
nodeid,
|
||||||
|
|
|
@ -152,6 +152,9 @@ public:
|
||||||
* skipping any combinations that have already been tried. Return the resulting package along with
|
* 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. */
|
* the senders of its respective transactions, or std::nullopt if no package is found. */
|
||||||
std::optional<PackageToValidate> Find1P1CPackage(const CTransactionRef& ptx, NodeId nodeid);
|
std::optional<PackageToValidate> Find1P1CPackage(const CTransactionRef& ptx, NodeId nodeid);
|
||||||
|
|
||||||
|
/** Respond to successful transaction submission to mempool */
|
||||||
|
void MempoolAcceptedTx(const CTransactionRef& tx);
|
||||||
};
|
};
|
||||||
} // namespace node
|
} // namespace node
|
||||||
#endif // BITCOIN_NODE_TXDOWNLOADMAN_H
|
#endif // BITCOIN_NODE_TXDOWNLOADMAN_H
|
||||||
|
|
|
@ -75,6 +75,10 @@ std::optional<PackageToValidate> TxDownloadManager::Find1P1CPackage(const CTrans
|
||||||
{
|
{
|
||||||
return m_impl->Find1P1CPackage(ptx, nodeid);
|
return m_impl->Find1P1CPackage(ptx, nodeid);
|
||||||
}
|
}
|
||||||
|
void TxDownloadManager::MempoolAcceptedTx(const CTransactionRef& tx)
|
||||||
|
{
|
||||||
|
m_impl->MempoolAcceptedTx(tx);
|
||||||
|
}
|
||||||
|
|
||||||
// TxDownloadManagerImpl
|
// TxDownloadManagerImpl
|
||||||
void TxDownloadManagerImpl::ActiveTipChange()
|
void TxDownloadManagerImpl::ActiveTipChange()
|
||||||
|
@ -272,4 +276,16 @@ std::optional<PackageToValidate> TxDownloadManagerImpl::Find1P1CPackage(const CT
|
||||||
}
|
}
|
||||||
return std::nullopt;
|
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
|
} // namespace node
|
||||||
|
|
|
@ -162,6 +162,8 @@ public:
|
||||||
void ReceivedNotFound(NodeId nodeid, const std::vector<uint256>& txhashes);
|
void ReceivedNotFound(NodeId nodeid, const std::vector<uint256>& txhashes);
|
||||||
|
|
||||||
std::optional<PackageToValidate> Find1P1CPackage(const CTransactionRef& ptx, NodeId nodeid);
|
std::optional<PackageToValidate> Find1P1CPackage(const CTransactionRef& ptx, NodeId nodeid);
|
||||||
|
|
||||||
|
void MempoolAcceptedTx(const CTransactionRef& tx);
|
||||||
};
|
};
|
||||||
} // namespace node
|
} // namespace node
|
||||||
#endif // BITCOIN_NODE_TXDOWNLOADMAN_IMPL_H
|
#endif // BITCOIN_NODE_TXDOWNLOADMAN_IMPL_H
|
||||||
|
|
Loading…
Add table
Reference in a new issue