aboutsummaryrefslogtreecommitdiff
path: root/src/net_processing.cpp
diff options
context:
space:
mode:
authorAnthony Towns <aj@erisian.com.au>2021-04-22 19:24:27 +1000
committerAnthony Towns <aj@erisian.com.au>2023-01-25 18:13:42 +1000
commitc5837757068bf8ea3e5b6fdad82f69d1deb81545 (patch)
treeaa837e30feba16f3c70a4d9b08d0145bfd11cb2d /src/net_processing.cpp
parentbe2304676bedcd15debcdc694549fdd2b255ba62 (diff)
downloadbitcoin-c5837757068bf8ea3e5b6fdad82f69d1deb81545.tar.xz
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().
Diffstat (limited to 'src/net_processing.cpp')
-rw-r--r--src/net_processing.cpp13
1 files changed, 3 insertions, 10 deletions
diff --git a/src/net_processing.cpp b/src/net_processing.cpp
index 9b9ef40001..25d9e75425 100644
--- a/src/net_processing.cpp
+++ b/src/net_processing.cpp
@@ -591,7 +591,7 @@ private:
* @return True if there are still orphans in this peer's work set.
*/
bool ProcessOrphanTx(Peer& peer)
- EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex, g_msgproc_mutex, cs_main);
+ EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex, g_msgproc_mutex);
/** Process a single headers message from a peer.
*
* @param[in] pfrom CNode of the peer
@@ -2889,7 +2889,7 @@ void PeerManagerImpl::ProcessHeadersMessage(CNode& pfrom, Peer& peer,
bool PeerManagerImpl::ProcessOrphanTx(Peer& peer)
{
AssertLockHeld(g_msgproc_mutex);
- AssertLockHeld(cs_main);
+ LOCK(cs_main);
CTransactionRef porphanTx = nullptr;
bool more = false;
@@ -4041,9 +4041,6 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
for (const CTransactionRef& removedTx : result.m_replaced_transactions.value()) {
AddToCompactExtraTransactions(removedTx);
}
-
- // Recursively process any orphan transactions that depended on this one
- ProcessOrphanTx(*peer);
}
else if (state.GetResult() == TxValidationResult::TX_MISSING_INPUTS)
{
@@ -4852,11 +4849,7 @@ bool PeerManagerImpl::ProcessMessages(CNode* pfrom, std::atomic<bool>& interrupt
}
}
- bool has_more_orphans;
- {
- LOCK(cs_main);
- has_more_orphans = ProcessOrphanTx(*peer);
- }
+ const bool has_more_orphans = ProcessOrphanTx(*peer);
if (pfrom->fDisconnect)
return false;