@@ -584,14 +584,17 @@ class PeerManagerImpl final : public PeerManager
584
584
/* *
585
585
* Reconsider orphan transactions after a parent has been accepted to the mempool.
586
586
*
587
- * @peer[in] peer The peer whose orphan transactions we will reconsider. Generally only one
588
- * orphan will be reconsidered on each call of this function. This set
589
- * may be added to if accepting an orphan causes its children to be
590
- * reconsidered.
591
- * @return True if there are still orphans in this peer's work set.
587
+ * @peer[in] peer The peer whose orphan transactions we will reconsider. Generally only
588
+ * one orphan will be reconsidered on each call of this function. If an
589
+ * accepted orphan has orphaned children, those will need to be
590
+ * reconsidered, creating more work, possibly for other peers.
591
+ * @return True if meaningful work was done (an orphan was accepted/rejected).
592
+ * If no meaningful work was done, then the work set for this peer
593
+ * will be empty.
592
594
*/
593
595
bool ProcessOrphanTx (Peer& peer)
594
596
EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex, g_msgproc_mutex);
597
+
595
598
/* * Process a single headers message from a peer.
596
599
*
597
600
* @param[in] pfrom CNode of the peer
@@ -2892,9 +2895,8 @@ bool PeerManagerImpl::ProcessOrphanTx(Peer& peer)
2892
2895
LOCK (cs_main);
2893
2896
2894
2897
CTransactionRef porphanTx = nullptr ;
2895
- bool more = false ;
2896
2898
2897
- while (CTransactionRef porphanTx = m_orphanage.GetTxToReconsider (peer.m_id , more )) {
2899
+ while (CTransactionRef porphanTx = m_orphanage.GetTxToReconsider (peer.m_id )) {
2898
2900
const MempoolAcceptResult result = m_chainman.ProcessTransaction (porphanTx);
2899
2901
const TxValidationState& state = result.m_state ;
2900
2902
const uint256& orphanHash = porphanTx->GetHash ();
@@ -2907,7 +2909,7 @@ bool PeerManagerImpl::ProcessOrphanTx(Peer& peer)
2907
2909
for (const CTransactionRef& removedTx : result.m_replaced_transactions .value ()) {
2908
2910
AddToCompactExtraTransactions (removedTx);
2909
2911
}
2910
- break ;
2912
+ return true ;
2911
2913
} else if (state.GetResult () != TxValidationResult::TX_MISSING_INPUTS) {
2912
2914
if (state.IsInvalid ()) {
2913
2915
LogPrint (BCLog::MEMPOOL, " invalid orphan tx %s from peer=%d. %s\n " ,
@@ -2950,11 +2952,11 @@ bool PeerManagerImpl::ProcessOrphanTx(Peer& peer)
2950
2952
}
2951
2953
}
2952
2954
m_orphanage.EraseTx (orphanHash);
2953
- break ;
2955
+ return true ;
2954
2956
}
2955
2957
}
2956
2958
2957
- return more ;
2959
+ return false ;
2958
2960
}
2959
2961
2960
2962
bool PeerManagerImpl::PrepareBlockFilterRequest (CNode& node, Peer& peer,
@@ -4849,12 +4851,12 @@ bool PeerManagerImpl::ProcessMessages(CNode* pfrom, std::atomic<bool>& interrupt
4849
4851
}
4850
4852
}
4851
4853
4852
- const bool has_more_orphans = ProcessOrphanTx (*peer);
4854
+ const bool processed_orphan = ProcessOrphanTx (*peer);
4853
4855
4854
4856
if (pfrom->fDisconnect )
4855
4857
return false ;
4856
4858
4857
- if (has_more_orphans ) return true ;
4859
+ if (processed_orphan ) return true ;
4858
4860
4859
4861
// this maintains the order of responses
4860
4862
// and prevents m_getdata_requests to grow unbounded
0 commit comments