@@ -301,6 +301,21 @@ void TxDownloadManagerImpl::MempoolAcceptedTx(const CTransactionRef& tx)
301
301
m_orphanage.EraseTx (tx->GetWitnessHash ());
302
302
}
303
303
304
+ std::vector<Txid> TxDownloadManagerImpl::GetUniqueParents (const CTransaction& tx)
305
+ {
306
+ std::vector<Txid> unique_parents;
307
+ unique_parents.reserve (tx.vin .size ());
308
+ for (const CTxIn& txin : tx.vin ) {
309
+ // We start with all parents, and then remove duplicates below.
310
+ unique_parents.push_back (txin.prevout .hash );
311
+ }
312
+
313
+ std::sort (unique_parents.begin (), unique_parents.end ());
314
+ unique_parents.erase (std::unique (unique_parents.begin (), unique_parents.end ()), unique_parents.end ());
315
+
316
+ return unique_parents;
317
+ }
318
+
304
319
node::RejectedTxTodo TxDownloadManagerImpl::MempoolRejectedTx (const CTransactionRef& ptx, const TxValidationState& state, NodeId nodeid, bool first_time_failure)
305
320
{
306
321
const CTransaction& tx{*ptx};
@@ -320,13 +335,7 @@ node::RejectedTxTodo TxDownloadManagerImpl::MempoolRejectedTx(const CTransaction
320
335
321
336
// Deduplicate parent txids, so that we don't have to loop over
322
337
// the same parent txid more than once down below.
323
- unique_parents.reserve (tx.vin .size ());
324
- for (const CTxIn& txin : tx.vin ) {
325
- // We start with all parents, and then remove duplicates below.
326
- unique_parents.push_back (txin.prevout .hash );
327
- }
328
- std::sort (unique_parents.begin (), unique_parents.end ());
329
- unique_parents.erase (std::unique (unique_parents.begin (), unique_parents.end ()), unique_parents.end ());
338
+ unique_parents = GetUniqueParents (tx);
330
339
331
340
// Distinguish between parents in m_lazy_recent_rejects and m_lazy_recent_rejects_reconsiderable.
332
341
// We can tolerate having up to 1 parent in m_lazy_recent_rejects_reconsiderable since we
0 commit comments