![]() |
Bitcoin Core
25.99.0
P2P Digital Currency
|
A class to track orphan transactions (failed on TX_MISSING_INPUTS) Since we cannot distinguish orphans from bad transactions with non-existent inputs, we heavily limit the number of orphans we keep and the duration we keep them for. More...
#include <txorphanage.h>
Classes | |
struct | IteratorComparator |
struct | OrphanTx |
Public Member Functions | |
bool | AddTx (const CTransactionRef &tx, NodeId peer) EXCLUSIVE_LOCKS_REQUIRED(!m_mutex) |
Add a new orphan transaction. More... | |
bool | HaveTx (const GenTxid >xid) const EXCLUSIVE_LOCKS_REQUIRED(!m_mutex) |
Check if we already have an orphan transaction (by txid or wtxid) More... | |
CTransactionRef | GetTxToReconsider (NodeId peer) EXCLUSIVE_LOCKS_REQUIRED(!m_mutex) |
Extract a transaction from a peer's work set Returns nullptr if there are no transactions to work on. More... | |
int | EraseTx (const uint256 &txid) EXCLUSIVE_LOCKS_REQUIRED(!m_mutex) |
Erase an orphan by txid. More... | |
void | EraseForPeer (NodeId peer) EXCLUSIVE_LOCKS_REQUIRED(!m_mutex) |
Erase all orphans announced by a peer (eg, after that peer disconnects) More... | |
void | EraseForBlock (const CBlock &block) EXCLUSIVE_LOCKS_REQUIRED(!m_mutex) |
Erase all orphans included in or invalidated by a new block. More... | |
void | LimitOrphans (unsigned int max_orphans) EXCLUSIVE_LOCKS_REQUIRED(!m_mutex) |
Limit the orphanage to the given maximum. More... | |
void | AddChildrenToWorkSet (const CTransaction &tx) EXCLUSIVE_LOCKS_REQUIRED(!m_mutex) |
Add any orphans that list a particular tx as a parent into the from peer's work set. More... | |
bool | HaveTxToReconsider (NodeId peer) EXCLUSIVE_LOCKS_REQUIRED(!m_mutex) |
Does this peer have any work to do? More... | |
size_t | Size () EXCLUSIVE_LOCKS_REQUIRED(!m_mutex) |
Return how many entries exist in the orphange. More... | |
Protected Types | |
using | OrphanMap = decltype(m_orphans) |
Protected Member Functions | |
std::map< uint256, OrphanTx > m_orphans | GUARDED_BY (m_mutex) |
Map from txid to orphan transaction record. More... | |
std::map< NodeId, std::set< uint256 > > m_peer_work_set | GUARDED_BY (m_mutex) |
Which peer provided the orphans that need to be reconsidered. More... | |
std::map< COutPoint, std::set< OrphanMap::iterator, IteratorComparator > > m_outpoint_to_orphan_it | GUARDED_BY (m_mutex) |
Index from the parents' COutPoint into the m_orphans. More... | |
std::vector< OrphanMap::iterator > m_orphan_list | GUARDED_BY (m_mutex) |
Orphan transactions in vector for quick random eviction. More... | |
std::map< uint256, OrphanMap::iterator > m_wtxid_to_orphan_it | GUARDED_BY (m_mutex) |
Index from wtxid into the m_orphans to lookup orphan transactions using their witness ids. More... | |
int | EraseTxNoLock (const uint256 &txid) EXCLUSIVE_LOCKS_REQUIRED(m_mutex) |
Erase an orphan by txid. More... | |
Protected Attributes | |
Mutex | m_mutex |
Guards orphan transactions. More... | |
A class to track orphan transactions (failed on TX_MISSING_INPUTS) Since we cannot distinguish orphans from bad transactions with non-existent inputs, we heavily limit the number of orphans we keep and the duration we keep them for.
Definition at line 21 of file txorphanage.h.
|
protected |
Definition at line 79 of file txorphanage.h.
void TxOrphanage::AddChildrenToWorkSet | ( | const CTransaction & | tx | ) |
Add any orphans that list a particular tx as a parent into the from peer's work set.
Definition at line 151 of file txorphanage.cpp.
bool TxOrphanage::AddTx | ( | const CTransactionRef & | tx, |
NodeId | peer | ||
) |
Add a new orphan transaction.
Definition at line 19 of file txorphanage.cpp.
void TxOrphanage::EraseForBlock | ( | const CBlock & | block | ) |
Erase all orphans included in or invalidated by a new block.
Definition at line 214 of file txorphanage.cpp.
void TxOrphanage::EraseForPeer | ( | NodeId | peer | ) |
Erase all orphans announced by a peer (eg, after that peer disconnects)
Definition at line 96 of file txorphanage.cpp.
int TxOrphanage::EraseTx | ( | const uint256 & | txid | ) |
Erase an orphan by txid.
Definition at line 56 of file txorphanage.cpp.
|
protected |
Erase an orphan by txid.
Definition at line 62 of file txorphanage.cpp.
CTransactionRef TxOrphanage::GetTxToReconsider | ( | NodeId | peer | ) |
Extract a transaction from a peer's work set Returns nullptr if there are no transactions to work on.
Otherwise returns the transaction reference, and removes it from the work set.
Definition at line 182 of file txorphanage.cpp.
Map from txid to orphan transaction record.
Limited by -maxorphantx/DEFAULT_MAX_ORPHAN_TRANSACTIONS
Which peer provided the orphans that need to be reconsidered.
|
protected |
Index from the parents' COutPoint into the m_orphans.
Used to remove orphan transactions from the m_orphans
|
protected |
Orphan transactions in vector for quick random eviction.
|
protected |
Index from wtxid into the m_orphans to lookup orphan transactions using their witness ids.
bool TxOrphanage::HaveTx | ( | const GenTxid & | gtxid | ) | const |
Check if we already have an orphan transaction (by txid or wtxid)
Definition at line 172 of file txorphanage.cpp.
bool TxOrphanage::HaveTxToReconsider | ( | NodeId | peer | ) |
Does this peer have any work to do?
Definition at line 202 of file txorphanage.cpp.
void TxOrphanage::LimitOrphans | ( | unsigned int | max_orphans | ) |
Limit the orphanage to the given maximum.
Definition at line 115 of file txorphanage.cpp.
|
inline |
Return how many entries exist in the orphange.
Definition at line 55 of file txorphanage.h.
|
mutableprotected |
Guards orphan transactions.
Definition at line 63 of file txorphanage.h.