@@ -1718,7 +1718,8 @@ void static ProcessOrphanTx(CConnman* connman, std::set<uint256>& orphan_work_se
1718
1718
AssertLockHeld (cs_main);
1719
1719
AssertLockHeld (g_cs_orphans);
1720
1720
std::set<NodeId> setMisbehaving;
1721
- while (!orphan_work_set.empty ()) {
1721
+ bool done = false ;
1722
+ while (!done && !orphan_work_set.empty ()) {
1722
1723
const uint256 orphanHash = *orphan_work_set.begin ();
1723
1724
orphan_work_set.erase (orphan_work_set.begin ());
1724
1725
@@ -1747,6 +1748,7 @@ void static ProcessOrphanTx(CConnman* connman, std::set<uint256>& orphan_work_se
1747
1748
}
1748
1749
}
1749
1750
EraseOrphanTx (orphanHash);
1751
+ done = true ;
1750
1752
} else if (!fMissingInputs2 ) {
1751
1753
int nDos = 0 ;
1752
1754
if (stateDummy.IsInvalid (nDos) && nDos > 0 ) {
@@ -1766,6 +1768,7 @@ void static ProcessOrphanTx(CConnman* connman, std::set<uint256>& orphan_work_se
1766
1768
recentRejects->insert (orphanHash);
1767
1769
}
1768
1770
EraseOrphanTx (orphanHash);
1771
+ done = true ;
1769
1772
}
1770
1773
mempool.check (pcoinsTip.get ());
1771
1774
}
@@ -2400,8 +2403,6 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
2400
2403
return true ;
2401
2404
}
2402
2405
2403
- std::set<uint256> orphan_work_set;
2404
-
2405
2406
CTransactionRef ptx;
2406
2407
vRecv >> ptx;
2407
2408
const CTransaction& tx = *ptx;
@@ -2429,7 +2430,7 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
2429
2430
auto it_by_prev = mapOrphanTransactionsByPrev.find (COutPoint (inv.hash , i));
2430
2431
if (it_by_prev != mapOrphanTransactionsByPrev.end ()) {
2431
2432
for (const auto & elem : it_by_prev->second ) {
2432
- orphan_work_set.insert (elem->first );
2433
+ pfrom-> orphan_work_set .insert (elem->first );
2433
2434
}
2434
2435
}
2435
2436
}
@@ -2442,7 +2443,7 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
2442
2443
mempool.size (), mempool.DynamicMemoryUsage () / 1000 );
2443
2444
2444
2445
// Recursively process any orphan transactions that depended on this one
2445
- ProcessOrphanTx (connman, orphan_work_set, lRemovedTxn);
2446
+ ProcessOrphanTx (connman, pfrom-> orphan_work_set , lRemovedTxn);
2446
2447
}
2447
2448
else if (fMissingInputs )
2448
2449
{
@@ -3174,11 +3175,21 @@ bool PeerLogicValidation::ProcessMessages(CNode* pfrom, std::atomic<bool>& inter
3174
3175
if (!pfrom->vRecvGetData .empty ())
3175
3176
ProcessGetData (pfrom, chainparams, connman, interruptMsgProc);
3176
3177
3178
+ if (!pfrom->orphan_work_set .empty ()) {
3179
+ std::list<CTransactionRef> removed_txn;
3180
+ LOCK2 (cs_main, g_cs_orphans);
3181
+ ProcessOrphanTx (connman, pfrom->orphan_work_set , removed_txn);
3182
+ for (const CTransactionRef& removedTx : removed_txn) {
3183
+ AddToCompactExtraTransactions (removedTx);
3184
+ }
3185
+ }
3186
+
3177
3187
if (pfrom->fDisconnect )
3178
3188
return false ;
3179
3189
3180
3190
// this maintains the order of responses
3181
3191
if (!pfrom->vRecvGetData .empty ()) return true ;
3192
+ if (!pfrom->orphan_work_set .empty ()) return true ;
3182
3193
3183
3194
// Don't bother if send buffer is too full to respond anyway
3184
3195
if (pfrom->fPauseSend )
0 commit comments