mirror of
https://github.com/bitcoin/bitcoin.git
synced 2024-11-19 01:42:58 +01:00
[refactor] wrap {Have,Get}TxToReconsider in txdownload
This commit is contained in:
parent
f150fb94e7
commit
969b07237b
@ -3076,7 +3076,7 @@ bool PeerManagerImpl::ProcessOrphanTx(Peer& peer)
|
||||
|
||||
CTransactionRef porphanTx = nullptr;
|
||||
|
||||
while (CTransactionRef porphanTx = m_txdownloadman.GetOrphanageRef().GetTxToReconsider(peer.m_id)) {
|
||||
while (CTransactionRef porphanTx = m_txdownloadman.GetTxToReconsider(peer.m_id)) {
|
||||
const MempoolAcceptResult result = m_chainman.ProcessTransaction(porphanTx);
|
||||
const TxValidationState& state = result.m_state;
|
||||
const Txid& orphanHash = porphanTx->GetHash();
|
||||
@ -5000,7 +5000,7 @@ bool PeerManagerImpl::ProcessMessages(CNode* pfrom, std::atomic<bool>& interrupt
|
||||
// the extra work may not be noticed, possibly resulting in an
|
||||
// unnecessary 100ms delay)
|
||||
LOCK(m_tx_download_mutex);
|
||||
if (m_txdownloadman.GetOrphanageRef().HaveTxToReconsider(peer->m_id)) fMoreWork = true;
|
||||
if (m_txdownloadman.HaveMoreWork(peer->m_id)) fMoreWork = true;
|
||||
} catch (const std::exception& e) {
|
||||
LogDebug(BCLog::NET, "%s(%s, %u bytes): Exception '%s' (%s) caught\n", __func__, SanitizeString(msg.m_type), msg.m_message_size, e.what(), typeid(e).name());
|
||||
} catch (...) {
|
||||
|
@ -161,6 +161,12 @@ public:
|
||||
* Return a bool indicating whether this tx should be validated. If false, optionally, a
|
||||
* PackageToValidate. */
|
||||
std::pair<bool, std::optional<PackageToValidate>> ReceivedTx(NodeId nodeid, const CTransactionRef& ptx);
|
||||
|
||||
/** Whether there are any orphans to reconsider for this peer. */
|
||||
bool HaveMoreWork(NodeId nodeid) const;
|
||||
|
||||
/** Returns next orphan tx to consider, or nullptr if none exist. */
|
||||
CTransactionRef GetTxToReconsider(NodeId nodeid);
|
||||
};
|
||||
} // namespace node
|
||||
#endif // BITCOIN_NODE_TXDOWNLOADMAN_H
|
||||
|
@ -75,6 +75,14 @@ std::pair<bool, std::optional<PackageToValidate>> TxDownloadManager::ReceivedTx(
|
||||
{
|
||||
return m_impl->ReceivedTx(nodeid, ptx);
|
||||
}
|
||||
bool TxDownloadManager::HaveMoreWork(NodeId nodeid) const
|
||||
{
|
||||
return m_impl->HaveMoreWork(nodeid);
|
||||
}
|
||||
CTransactionRef TxDownloadManager::GetTxToReconsider(NodeId nodeid)
|
||||
{
|
||||
return m_impl->GetTxToReconsider(nodeid);
|
||||
}
|
||||
|
||||
// TxDownloadManagerImpl
|
||||
void TxDownloadManagerImpl::ActiveTipChange()
|
||||
@ -496,4 +504,15 @@ std::pair<bool, std::optional<PackageToValidate>> TxDownloadManagerImpl::Receive
|
||||
|
||||
return {true, std::nullopt};
|
||||
}
|
||||
|
||||
bool TxDownloadManagerImpl::HaveMoreWork(NodeId nodeid)
|
||||
{
|
||||
return m_orphanage.HaveTxToReconsider(nodeid);
|
||||
}
|
||||
|
||||
CTransactionRef TxDownloadManagerImpl::GetTxToReconsider(NodeId nodeid)
|
||||
{
|
||||
return m_orphanage.GetTxToReconsider(nodeid);
|
||||
}
|
||||
|
||||
} // namespace node
|
||||
|
@ -179,6 +179,9 @@ public:
|
||||
void MempoolRejectedPackage(const Package& package);
|
||||
|
||||
std::pair<bool, std::optional<PackageToValidate>> ReceivedTx(NodeId nodeid, const CTransactionRef& ptx);
|
||||
|
||||
bool HaveMoreWork(NodeId nodeid);
|
||||
CTransactionRef GetTxToReconsider(NodeId nodeid);
|
||||
};
|
||||
} // namespace node
|
||||
#endif // BITCOIN_NODE_TXDOWNLOADMAN_IMPL_H
|
||||
|
Loading…
Reference in New Issue
Block a user