mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-08 10:31:50 -05:00
Add wtxid-index to orphan map
This commit is contained in:
parent
08b39955ec
commit
85c78d54af
1 changed files with 5 additions and 0 deletions
|
@ -151,6 +151,7 @@ struct COrphanTx {
|
||||||
};
|
};
|
||||||
RecursiveMutex g_cs_orphans;
|
RecursiveMutex g_cs_orphans;
|
||||||
std::map<uint256, COrphanTx> mapOrphanTransactions GUARDED_BY(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);
|
void EraseOrphansFor(NodeId peer);
|
||||||
|
|
||||||
|
@ -936,6 +937,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()});
|
auto ret = mapOrphanTransactions.emplace(hash, COrphanTx{tx, peer, GetTime() + ORPHAN_TX_EXPIRE_TIME, g_orphan_list.size()});
|
||||||
assert(ret.second);
|
assert(ret.second);
|
||||||
g_orphan_list.push_back(ret.first);
|
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) {
|
for (const CTxIn& txin : tx->vin) {
|
||||||
mapOrphanTransactionsByPrev[txin.prevout].insert(ret.first);
|
mapOrphanTransactionsByPrev[txin.prevout].insert(ret.first);
|
||||||
}
|
}
|
||||||
|
@ -972,6 +975,7 @@ int static EraseOrphanTx(uint256 hash) EXCLUSIVE_LOCKS_REQUIRED(g_cs_orphans)
|
||||||
it_last->second.list_pos = old_pos;
|
it_last->second.list_pos = old_pos;
|
||||||
}
|
}
|
||||||
g_orphan_list.pop_back();
|
g_orphan_list.pop_back();
|
||||||
|
g_orphans_by_wtxid.erase(it->second.tx->GetWitnessHash());
|
||||||
|
|
||||||
mapOrphanTransactions.erase(it);
|
mapOrphanTransactions.erase(it);
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -4464,6 +4468,7 @@ public:
|
||||||
// orphan transactions
|
// orphan transactions
|
||||||
mapOrphanTransactions.clear();
|
mapOrphanTransactions.clear();
|
||||||
mapOrphanTransactionsByPrev.clear();
|
mapOrphanTransactionsByPrev.clear();
|
||||||
|
g_orphans_by_wtxid.clear();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
static CNetProcessingCleanup instance_of_cnetprocessingcleanup;
|
static CNetProcessingCleanup instance_of_cnetprocessingcleanup;
|
||||||
|
|
Loading…
Add table
Reference in a new issue