@@ -1346,7 +1346,8 @@ void static ProcessOrphanTx(CConnman* connman, std::set<uint256>& orphan_work_se
1346
1346
{
1347
1347
AssertLockHeld (cs_main);
1348
1348
std::set<NodeId> setMisbehaving;
1349
- while (!orphan_work_set.empty ()) {
1349
+ bool done = false ;
1350
+ while (!done && !orphan_work_set.empty ()) {
1350
1351
const uint256 orphanHash = *orphan_work_set.begin ();
1351
1352
1352
1353
orphan_work_set.erase (orphan_work_set.begin ());
@@ -1381,6 +1382,7 @@ void static ProcessOrphanTx(CConnman* connman, std::set<uint256>& orphan_work_se
1381
1382
}
1382
1383
1383
1384
EraseOrphanTx (orphanHash);
1385
+ done = true ;
1384
1386
1385
1387
} else if (!fMissingInputs2 ) {
1386
1388
@@ -1403,6 +1405,7 @@ void static ProcessOrphanTx(CConnman* connman, std::set<uint256>& orphan_work_se
1403
1405
}
1404
1406
1405
1407
EraseOrphanTx (orphanHash);
1408
+ done = true ;
1406
1409
1407
1410
}
1408
1411
@@ -2073,7 +2076,6 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
2073
2076
return true ;
2074
2077
}
2075
2078
2076
- std::set<uint256> orphan_work_set;
2077
2079
CTransactionRef ptx;
2078
2080
vRecv >> ptx;
2079
2081
const CTransaction& tx = *ptx;
@@ -2100,7 +2102,7 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
2100
2102
auto it_by_prev = mapOrphanTransactionsByPrev.find (COutPoint (inv.hash , i));
2101
2103
if (it_by_prev != mapOrphanTransactionsByPrev.end ()) {
2102
2104
for (const auto & elem : it_by_prev->second ) {
2103
- orphan_work_set.insert (elem->first );
2105
+ pfrom-> orphan_work_set .insert (elem->first );
2104
2106
}
2105
2107
}
2106
2108
}
@@ -2113,7 +2115,7 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
2113
2115
mempool.size (), mempool.DynamicMemoryUsage () / 1000 );
2114
2116
2115
2117
// Recursively process any orphan transactions that depended on this one
2116
- ProcessOrphanTx (&connman, orphan_work_set, lRemovedTxn);
2118
+ ProcessOrphanTx (&connman, pfrom-> orphan_work_set , lRemovedTxn);
2117
2119
}
2118
2120
else if (fMissingInputs )
2119
2121
{
@@ -2926,11 +2928,21 @@ bool ProcessMessages(CNode* pfrom, CConnman& connman, const std::atomic<bool>& i
2926
2928
if (!pfrom->vRecvGetData .empty ())
2927
2929
ProcessGetData (pfrom, chainparams.GetConsensus (chainActive.Height ()), connman, interruptMsgProc);
2928
2930
2931
+ if (!pfrom->orphan_work_set .empty ()) {
2932
+ std::list<CTransactionRef> removed_txn;
2933
+ LOCK (cs_main);
2934
+ ProcessOrphanTx (&connman, pfrom->orphan_work_set , removed_txn);
2935
+ for (const CTransactionRef& removedTx : removed_txn) {
2936
+ AddToCompactExtraTransactions (removedTx);
2937
+ }
2938
+ }
2939
+
2929
2940
if (pfrom->fDisconnect )
2930
2941
return false ;
2931
2942
2932
2943
// this maintains the order of responses
2933
2944
if (!pfrom->vRecvGetData .empty ()) return true ;
2945
+ if (!pfrom->orphan_work_set .empty ()) return true ;
2934
2946
2935
2947
// Don't bother if send buffer is too full to respond anyway
2936
2948
if (pfrom->fPauseSend )
0 commit comments