mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-29 14:59:39 -04:00
[refactor] wrap {Have,Get}TxToReconsider in txdownload
This commit is contained in:
parent
f150fb94e7
commit
969b07237b
4 changed files with 30 additions and 2 deletions
|
@ -3076,7 +3076,7 @@ bool PeerManagerImpl::ProcessOrphanTx(Peer& peer)
|
||||||
|
|
||||||
CTransactionRef porphanTx = nullptr;
|
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 MempoolAcceptResult result = m_chainman.ProcessTransaction(porphanTx);
|
||||||
const TxValidationState& state = result.m_state;
|
const TxValidationState& state = result.m_state;
|
||||||
const Txid& orphanHash = porphanTx->GetHash();
|
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
|
// the extra work may not be noticed, possibly resulting in an
|
||||||
// unnecessary 100ms delay)
|
// unnecessary 100ms delay)
|
||||||
LOCK(m_tx_download_mutex);
|
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) {
|
} 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());
|
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 (...) {
|
} catch (...) {
|
||||||
|
|
|
@ -161,6 +161,12 @@ public:
|
||||||
* Return a bool indicating whether this tx should be validated. If false, optionally, a
|
* Return a bool indicating whether this tx should be validated. If false, optionally, a
|
||||||
* PackageToValidate. */
|
* PackageToValidate. */
|
||||||
std::pair<bool, std::optional<PackageToValidate>> ReceivedTx(NodeId nodeid, const CTransactionRef& ptx);
|
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
|
} // namespace node
|
||||||
#endif // BITCOIN_NODE_TXDOWNLOADMAN_H
|
#endif // BITCOIN_NODE_TXDOWNLOADMAN_H
|
||||||
|
|
|
@ -75,6 +75,14 @@ std::pair<bool, std::optional<PackageToValidate>> TxDownloadManager::ReceivedTx(
|
||||||
{
|
{
|
||||||
return m_impl->ReceivedTx(nodeid, ptx);
|
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
|
// TxDownloadManagerImpl
|
||||||
void TxDownloadManagerImpl::ActiveTipChange()
|
void TxDownloadManagerImpl::ActiveTipChange()
|
||||||
|
@ -496,4 +504,15 @@ std::pair<bool, std::optional<PackageToValidate>> TxDownloadManagerImpl::Receive
|
||||||
|
|
||||||
return {true, std::nullopt};
|
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
|
} // namespace node
|
||||||
|
|
|
@ -179,6 +179,9 @@ public:
|
||||||
void MempoolRejectedPackage(const Package& package);
|
void MempoolRejectedPackage(const Package& package);
|
||||||
|
|
||||||
std::pair<bool, std::optional<PackageToValidate>> ReceivedTx(NodeId nodeid, const CTransactionRef& ptx);
|
std::pair<bool, std::optional<PackageToValidate>> ReceivedTx(NodeId nodeid, const CTransactionRef& ptx);
|
||||||
|
|
||||||
|
bool HaveMoreWork(NodeId nodeid);
|
||||||
|
CTransactionRef GetTxToReconsider(NodeId nodeid);
|
||||||
};
|
};
|
||||||
} // namespace node
|
} // namespace node
|
||||||
#endif // BITCOIN_NODE_TXDOWNLOADMAN_IMPL_H
|
#endif // BITCOIN_NODE_TXDOWNLOADMAN_IMPL_H
|
||||||
|
|
Loading…
Add table
Reference in a new issue