@@ -151,6 +151,7 @@ struct COrphanTx {
151
151
};
152
152
RecursiveMutex g_cs_orphans;
153
153
std::map<uint256, COrphanTx> mapOrphanTransactions GUARDED_BY (g_cs_orphans);
154
+ std::map<uint256, std::map<uint256, COrphanTx>::iterator> g_orphans_by_wtxid GUARDED_BY (g_cs_orphans);
154
155
155
156
void EraseOrphansFor (NodeId peer);
156
157
@@ -936,6 +937,8 @@ bool AddOrphanTx(const CTransactionRef& tx, NodeId peer) EXCLUSIVE_LOCKS_REQUIRE
936
937
auto ret = mapOrphanTransactions.emplace (hash, COrphanTx{tx, peer, GetTime () + ORPHAN_TX_EXPIRE_TIME, g_orphan_list.size ()});
937
938
assert (ret.second );
938
939
g_orphan_list.push_back (ret.first );
940
+ // Allow for lookups in the orphan pool by wtxid, as well as txid
941
+ g_orphans_by_wtxid.emplace (tx->GetWitnessHash (), ret.first );
939
942
for (const CTxIn& txin : tx->vin ) {
940
943
mapOrphanTransactionsByPrev[txin.prevout ].insert (ret.first );
941
944
}
@@ -972,6 +975,7 @@ int static EraseOrphanTx(uint256 hash) EXCLUSIVE_LOCKS_REQUIRED(g_cs_orphans)
972
975
it_last->second .list_pos = old_pos;
973
976
}
974
977
g_orphan_list.pop_back ();
978
+ g_orphans_by_wtxid.erase (it->second .tx ->GetWitnessHash ());
975
979
976
980
mapOrphanTransactions.erase (it);
977
981
return 1 ;
@@ -4464,6 +4468,7 @@ class CNetProcessingCleanup
4464
4468
// orphan transactions
4465
4469
mapOrphanTransactions.clear ();
4466
4470
mapOrphanTransactionsByPrev.clear ();
4471
+ g_orphans_by_wtxid.clear ();
4467
4472
}
4468
4473
};
4469
4474
static CNetProcessingCleanup instance_of_cnetprocessingcleanup;
0 commit comments