Skip to content

Commit 6e8dd99

Browse files
committed
[net processing] Add doxygen comments for orphan data and function
1 parent 147d50d commit 6e8dd99

File tree

1 file changed

+26
-3
lines changed

1 file changed

+26
-3
lines changed

src/net_processing.cpp

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,14 @@ struct COrphanTx {
153153
int64_t nTimeExpire;
154154
size_t list_pos;
155155
};
156+
157+
/** Guards orphan transactions and extra txs for compact blocks */
156158
RecursiveMutex g_cs_orphans;
159+
/** Map from txid to orphan transaction record. Limited by
160+
* -maxorphantx/DEFAULT_MAX_ORPHAN_TRANSACTIONS */
157161
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. */
158164
std::map<uint256, std::map<uint256, COrphanTx>::iterator> g_orphans_by_wtxid GUARDED_BY(g_cs_orphans);
159165

160166
void EraseOrphansFor(NodeId peer);
@@ -258,12 +264,19 @@ namespace {
258264
return &(*a) < &(*b);
259265
}
260266
};
261-
std::map<COutPoint, std::set<std::map<uint256, COrphanTx>::iterator, IteratorComparator>> mapOrphanTransactionsByPrev GUARDED_BY(g_cs_orphans);
262267

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);
264273

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 */
266277
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;
267280
} // namespace
268281

269282
namespace {
@@ -2021,6 +2034,16 @@ void PeerManager::ProcessHeadersMessage(CNode& pfrom, const std::vector<CBlockHe
20212034
return;
20222035
}
20232036

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+
*/
20242047
void PeerManager::ProcessOrphanTx(std::set<uint256>& orphan_work_set, std::list<CTransactionRef>& removed_txn)
20252048
{
20262049
AssertLockHeld(cs_main);

0 commit comments

Comments
 (0)