aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSuhas Daftuar <sdaftuar@gmail.com>2020-01-29 10:51:45 -0500
committerJohn Newbery <john@johnnewbery.com>2020-09-24 13:24:10 +0100
commit606755b840b1560e4f92c9252fa4cab6eacabdd3 (patch)
tree619f31f0aa1ea958a1297f13f4ca2125cbc51c31
parent36549376740d28159a5834ecf4ed9eeeeef6715d (diff)
downloadbitcoin-606755b840b1560e4f92c9252fa4cab6eacabdd3.tar.xz
Add wtxid-index to orphan map
-rw-r--r--src/net_processing.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/net_processing.cpp b/src/net_processing.cpp
index b6822d9303..c168531e3a 100644
--- a/src/net_processing.cpp
+++ b/src/net_processing.cpp
@@ -91,6 +91,7 @@ struct COrphanTx {
};
RecursiveMutex g_cs_orphans;
std::map<uint256, COrphanTx> mapOrphanTransactions GUARDED_BY(g_cs_orphans);
+std::map<uint256, std::map<uint256, COrphanTx>::iterator> g_orphans_by_wtxid GUARDED_BY(g_cs_orphans);
void EraseOrphansFor(NodeId peer);
@@ -868,6 +869,8 @@ bool AddOrphanTx(const CTransactionRef& tx, NodeId peer) EXCLUSIVE_LOCKS_REQUIRE
auto ret = mapOrphanTransactions.emplace(hash, COrphanTx{tx, peer, GetTime() + ORPHAN_TX_EXPIRE_TIME, g_orphan_list.size()});
assert(ret.second);
g_orphan_list.push_back(ret.first);
+ // Allow for lookups in the orphan pool by wtxid, as well as txid
+ g_orphans_by_wtxid.emplace(tx->GetWitnessHash(), ret.first);
for (const CTxIn& txin : tx->vin) {
mapOrphanTransactionsByPrev[txin.prevout].insert(ret.first);
}
@@ -904,6 +907,7 @@ int static EraseOrphanTx(uint256 hash) EXCLUSIVE_LOCKS_REQUIRED(g_cs_orphans)
it_last->second.list_pos = old_pos;
}
g_orphan_list.pop_back();
+ g_orphans_by_wtxid.erase(it->second.tx->GetWitnessHash());
mapOrphanTransactions.erase(it);
return 1;
@@ -4139,6 +4143,7 @@ public:
// orphan transactions
mapOrphanTransactions.clear();
mapOrphanTransactionsByPrev.clear();
+ g_orphans_by_wtxid.clear();
}
};
static CNetProcessingCleanup instance_of_cnetprocessingcleanup;