Skip to content

Commit 969b072

Browse files
committed
[refactor] wrap {Have,Get}TxToReconsider in txdownload
1 parent f150fb9 commit 969b072

File tree

4 files changed

+30
-2
lines changed

4 files changed

+30
-2
lines changed

src/net_processing.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3076,7 +3076,7 @@ bool PeerManagerImpl::ProcessOrphanTx(Peer& peer)
30763076

30773077
CTransactionRef porphanTx = nullptr;
30783078

3079-
while (CTransactionRef porphanTx = m_txdownloadman.GetOrphanageRef().GetTxToReconsider(peer.m_id)) {
3079+
while (CTransactionRef porphanTx = m_txdownloadman.GetTxToReconsider(peer.m_id)) {
30803080
const MempoolAcceptResult result = m_chainman.ProcessTransaction(porphanTx);
30813081
const TxValidationState& state = result.m_state;
30823082
const Txid& orphanHash = porphanTx->GetHash();
@@ -5000,7 +5000,7 @@ bool PeerManagerImpl::ProcessMessages(CNode* pfrom, std::atomic<bool>& interrupt
50005000
// the extra work may not be noticed, possibly resulting in an
50015001
// unnecessary 100ms delay)
50025002
LOCK(m_tx_download_mutex);
5003-
if (m_txdownloadman.GetOrphanageRef().HaveTxToReconsider(peer->m_id)) fMoreWork = true;
5003+
if (m_txdownloadman.HaveMoreWork(peer->m_id)) fMoreWork = true;
50045004
} catch (const std::exception& e) {
50055005
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());
50065006
} catch (...) {

src/node/txdownloadman.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,12 @@ class TxDownloadManager {
161161
* Return a bool indicating whether this tx should be validated. If false, optionally, a
162162
* PackageToValidate. */
163163
std::pair<bool, std::optional<PackageToValidate>> ReceivedTx(NodeId nodeid, const CTransactionRef& ptx);
164+
165+
/** Whether there are any orphans to reconsider for this peer. */
166+
bool HaveMoreWork(NodeId nodeid) const;
167+
168+
/** Returns next orphan tx to consider, or nullptr if none exist. */
169+
CTransactionRef GetTxToReconsider(NodeId nodeid);
164170
};
165171
} // namespace node
166172
#endif // BITCOIN_NODE_TXDOWNLOADMAN_H

src/node/txdownloadman_impl.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,14 @@ std::pair<bool, std::optional<PackageToValidate>> TxDownloadManager::ReceivedTx(
7575
{
7676
return m_impl->ReceivedTx(nodeid, ptx);
7777
}
78+
bool TxDownloadManager::HaveMoreWork(NodeId nodeid) const
79+
{
80+
return m_impl->HaveMoreWork(nodeid);
81+
}
82+
CTransactionRef TxDownloadManager::GetTxToReconsider(NodeId nodeid)
83+
{
84+
return m_impl->GetTxToReconsider(nodeid);
85+
}
7886

7987
// TxDownloadManagerImpl
8088
void TxDownloadManagerImpl::ActiveTipChange()
@@ -496,4 +504,15 @@ std::pair<bool, std::optional<PackageToValidate>> TxDownloadManagerImpl::Receive
496504

497505
return {true, std::nullopt};
498506
}
507+
508+
bool TxDownloadManagerImpl::HaveMoreWork(NodeId nodeid)
509+
{
510+
return m_orphanage.HaveTxToReconsider(nodeid);
511+
}
512+
513+
CTransactionRef TxDownloadManagerImpl::GetTxToReconsider(NodeId nodeid)
514+
{
515+
return m_orphanage.GetTxToReconsider(nodeid);
516+
}
517+
499518
} // namespace node

src/node/txdownloadman_impl.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,9 @@ class TxDownloadManagerImpl {
179179
void MempoolRejectedPackage(const Package& package);
180180

181181
std::pair<bool, std::optional<PackageToValidate>> ReceivedTx(NodeId nodeid, const CTransactionRef& ptx);
182+
183+
bool HaveMoreWork(NodeId nodeid);
184+
CTransactionRef GetTxToReconsider(NodeId nodeid);
182185
};
183186
} // namespace node
184187
#endif // BITCOIN_NODE_TXDOWNLOADMAN_IMPL_H

0 commit comments

Comments
 (0)