Skip to content

Commit 001343f

Browse files
committed
ProcessOrphanTx: Move AddToCompactExtraTransactions call into ProcessOrphanTx
1 parent 4fce726 commit 001343f

File tree

2 files changed

+12
-14
lines changed

2 files changed

+12
-14
lines changed

src/net_processing.cpp

+11-12
Original file line numberDiff line numberDiff line change
@@ -2041,10 +2041,8 @@ void PeerManager::ProcessHeadersMessage(CNode& pfrom, const std::vector<CBlockHe
20412041
* orphan will be reconsidered on each call of this function. This set
20422042
* may be added to if accepting an orphan causes its children to be
20432043
* reconsidered.
2044-
* @param[out] removed_txn Transactions that were removed from the mempool as a result of an
2045-
* orphan transaction being added.
20462044
*/
2047-
void PeerManager::ProcessOrphanTx(std::set<uint256>& orphan_work_set, std::list<CTransactionRef>& removed_txn)
2045+
void PeerManager::ProcessOrphanTx(std::set<uint256>& orphan_work_set)
20482046
{
20492047
AssertLockHeld(cs_main);
20502048
AssertLockHeld(g_cs_orphans);
@@ -2058,6 +2056,7 @@ void PeerManager::ProcessOrphanTx(std::set<uint256>& orphan_work_set, std::list<
20582056

20592057
const CTransactionRef porphanTx = orphan_it->second.tx;
20602058
TxValidationState state;
2059+
std::list<CTransactionRef> removed_txn;
20612060

20622061
if (AcceptToMemoryPool(m_mempool, state, porphanTx, &removed_txn, false /* bypass_limits */, 0 /* nAbsurdFee */)) {
20632062
LogPrint(BCLog::MEMPOOL, " accepted orphan tx %s\n", orphanHash.ToString());
@@ -2071,6 +2070,9 @@ void PeerManager::ProcessOrphanTx(std::set<uint256>& orphan_work_set, std::list<
20712070
}
20722071
}
20732072
EraseOrphanTx(orphanHash);
2073+
for (const CTransactionRef& removedTx : removed_txn) {
2074+
AddToCompactExtraTransactions(removedTx);
2075+
}
20742076
break;
20752077
} else if (state.GetResult() != TxValidationResult::TX_MISSING_INPUTS) {
20762078
if (state.IsInvalid()) {
@@ -3034,8 +3036,12 @@ void PeerManager::ProcessMessage(CNode& pfrom, const std::string& msg_type, CDat
30343036
tx.GetHash().ToString(),
30353037
m_mempool.size(), m_mempool.DynamicMemoryUsage() / 1000);
30363038

3039+
for (const CTransactionRef& removedTx : lRemovedTxn) {
3040+
AddToCompactExtraTransactions(removedTx);
3041+
}
3042+
30373043
// Recursively process any orphan transactions that depended on this one
3038-
ProcessOrphanTx(pfrom.orphan_work_set, lRemovedTxn);
3044+
ProcessOrphanTx(pfrom.orphan_work_set);
30393045
}
30403046
else if (state.GetResult() == TxValidationResult::TX_MISSING_INPUTS)
30413047
{
@@ -3138,9 +3144,6 @@ void PeerManager::ProcessMessage(CNode& pfrom, const std::string& msg_type, CDat
31383144
}
31393145
}
31403146

3141-
for (const CTransactionRef& removedTx : lRemovedTxn)
3142-
AddToCompactExtraTransactions(removedTx);
3143-
31443147
// If a tx has been detected by recentRejects, we will have reached
31453148
// this point and the tx will have been ignored. Because we haven't run
31463149
// the tx through AcceptToMemoryPool, we won't have computed a DoS
@@ -3853,12 +3856,8 @@ bool PeerManager::ProcessMessages(CNode* pfrom, std::atomic<bool>& interruptMsgP
38533856
ProcessGetData(*pfrom, m_chainparams, m_connman, m_mempool, interruptMsgProc);
38543857

38553858
if (!pfrom->orphan_work_set.empty()) {
3856-
std::list<CTransactionRef> removed_txn;
38573859
LOCK2(cs_main, g_cs_orphans);
3858-
ProcessOrphanTx(pfrom->orphan_work_set, removed_txn);
3859-
for (const CTransactionRef& removedTx : removed_txn) {
3860-
AddToCompactExtraTransactions(removedTx);
3861-
}
3860+
ProcessOrphanTx(pfrom->orphan_work_set);
38623861
}
38633862

38643863
if (pfrom->fDisconnect)

src/net_processing.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,7 @@ class PeerManager final : public CValidationInterface, public NetEventsInterface
121121
*/
122122
bool MaybeDiscourageAndDisconnect(CNode& pnode);
123123

124-
void ProcessOrphanTx(std::set<uint256>& orphan_work_set, std::list<CTransactionRef>& removed_txn)
125-
EXCLUSIVE_LOCKS_REQUIRED(cs_main, g_cs_orphans);
124+
void ProcessOrphanTx(std::set<uint256>& orphan_work_set) EXCLUSIVE_LOCKS_REQUIRED(cs_main, g_cs_orphans);
126125
/** Process a single headers message from a peer. */
127126
void ProcessHeadersMessage(CNode& pfrom, const std::vector<CBlockHeader>& headers, bool via_compact_block);
128127

0 commit comments

Comments
 (0)