Skip to content

Commit c583775

Browse files
committed
net_processing: only process orphans before messages
Previously, when we processed a new tx we would attempt to ATMP any orphans that considered the new tx a parent immediately, but would only accept at most one such tx, leaving any others to be considered on a future run of ProcessMessages(). With this patch, we don't attempt any orphan processing immediately after receiving a tx, instead deferring all of them until the next call to ProcessMessages().
1 parent be23046 commit c583775

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

src/net_processing.cpp

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,7 @@ class PeerManagerImpl final : public PeerManager
591591
* @return True if there are still orphans in this peer's work set.
592592
*/
593593
bool ProcessOrphanTx(Peer& peer)
594-
EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex, g_msgproc_mutex, cs_main);
594+
EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex, g_msgproc_mutex);
595595
/** Process a single headers message from a peer.
596596
*
597597
* @param[in] pfrom CNode of the peer
@@ -2889,7 +2889,7 @@ void PeerManagerImpl::ProcessHeadersMessage(CNode& pfrom, Peer& peer,
28892889
bool PeerManagerImpl::ProcessOrphanTx(Peer& peer)
28902890
{
28912891
AssertLockHeld(g_msgproc_mutex);
2892-
AssertLockHeld(cs_main);
2892+
LOCK(cs_main);
28932893

28942894
CTransactionRef porphanTx = nullptr;
28952895
bool more = false;
@@ -4041,9 +4041,6 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
40414041
for (const CTransactionRef& removedTx : result.m_replaced_transactions.value()) {
40424042
AddToCompactExtraTransactions(removedTx);
40434043
}
4044-
4045-
// Recursively process any orphan transactions that depended on this one
4046-
ProcessOrphanTx(*peer);
40474044
}
40484045
else if (state.GetResult() == TxValidationResult::TX_MISSING_INPUTS)
40494046
{
@@ -4852,11 +4849,7 @@ bool PeerManagerImpl::ProcessMessages(CNode* pfrom, std::atomic<bool>& interrupt
48524849
}
48534850
}
48544851

4855-
bool has_more_orphans;
4856-
{
4857-
LOCK(cs_main);
4858-
has_more_orphans = ProcessOrphanTx(*peer);
4859-
}
4852+
const bool has_more_orphans = ProcessOrphanTx(*peer);
48604853

48614854
if (pfrom->fDisconnect)
48624855
return false;

0 commit comments

Comments
 (0)