@@ -153,8 +153,14 @@ struct COrphanTx {
153
153
int64_t nTimeExpire;
154
154
size_t list_pos;
155
155
};
156
+
157
+ /* * Guards orphan transactions and extra txs for compact blocks */
156
158
RecursiveMutex g_cs_orphans;
159
+ /* * Map from txid to orphan transaction record. Limited by
160
+ * -maxorphantx/DEFAULT_MAX_ORPHAN_TRANSACTIONS */
157
161
std::map<uint256, COrphanTx> mapOrphanTransactions GUARDED_BY (g_cs_orphans);
162
+ /* * Index from wtxid into the mapOrphanTransactions to lookup orphan
163
+ * transactions using their witness ids. */
158
164
std::map<uint256, std::map<uint256, COrphanTx>::iterator> g_orphans_by_wtxid GUARDED_BY (g_cs_orphans);
159
165
160
166
void EraseOrphansFor (NodeId peer);
@@ -258,12 +264,19 @@ namespace {
258
264
return &(*a) < &(*b);
259
265
}
260
266
};
261
- std::map<COutPoint, std::set<std::map<uint256, COrphanTx>::iterator, IteratorComparator>> mapOrphanTransactionsByPrev GUARDED_BY (g_cs_orphans);
262
267
263
- std::vector<std::map<uint256, COrphanTx>::iterator> g_orphan_list GUARDED_BY (g_cs_orphans); // ! For random eviction
268
+ /* * Index from the parents' COutPoint into the mapOrphanTransactions. Used
269
+ * to remove orphan transactions from the mapOrphanTransactions */
270
+ std::map<COutPoint, std::set<std::map<uint256, COrphanTx>::iterator, IteratorComparator>> mapOrphanTransactionsByPrev GUARDED_BY (g_cs_orphans);
271
+ /* * Orphan transactions in vector for quick random eviction */
272
+ std::vector<std::map<uint256, COrphanTx>::iterator> g_orphan_list GUARDED_BY (g_cs_orphans);
264
273
265
- static size_t vExtraTxnForCompactIt GUARDED_BY (g_cs_orphans) = 0;
274
+ /* * Orphan/conflicted/etc transactions that are kept for compact block reconstruction.
275
+ * The last -blockreconstructionextratxn/DEFAULT_BLOCK_RECONSTRUCTION_EXTRA_TXN of
276
+ * these are kept in a ring buffer */
266
277
static std::vector<std::pair<uint256, CTransactionRef>> vExtraTxnForCompact GUARDED_BY (g_cs_orphans);
278
+ /* * Offset into vExtraTxnForCompact to insert the next tx */
279
+ static size_t vExtraTxnForCompactIt GUARDED_BY (g_cs_orphans) = 0;
267
280
} // namespace
268
281
269
282
namespace {
@@ -2021,6 +2034,16 @@ void PeerManager::ProcessHeadersMessage(CNode& pfrom, const std::vector<CBlockHe
2021
2034
return ;
2022
2035
}
2023
2036
2037
+ /* *
2038
+ * Reconsider orphan transactions after a parent has been accepted to the mempool.
2039
+ *
2040
+ * @param[in/out] orphan_work_set The set of orphan transactions to reconsider. Generally only one
2041
+ * orphan will be reconsidered on each call of this function. This set
2042
+ * may be added to if accepting an orphan causes its children to be
2043
+ * reconsidered.
2044
+ * @param[out] removed_txn Transactions that were removed from the mempool as a result of an
2045
+ * orphan transaction being added.
2046
+ */
2024
2047
void PeerManager::ProcessOrphanTx (std::set<uint256>& orphan_work_set, std::list<CTransactionRef>& removed_txn)
2025
2048
{
2026
2049
AssertLockHeld (cs_main);
0 commit comments