![]() |
Bitcoin ABC
0.26.3
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(g_cs_orphans) |
Add a new orphan transaction. More... | |
bool | HaveTx (const TxId &txid) const LOCKS_EXCLUDED(g_cs_orphans) |
Check if we already have an orphan transaction. More... | |
std::pair< CTransactionRef, NodeId > | GetTx (const TxId &txid) const EXCLUSIVE_LOCKS_REQUIRED(g_cs_orphans) |
Get an orphan transaction and its originating peer (Transaction ref will be nullptr if not found) More... | |
int | EraseTx (const TxId &txid) EXCLUSIVE_LOCKS_REQUIRED(g_cs_orphans) |
Erase an orphan by txid. More... | |
void | EraseForPeer (NodeId peer) EXCLUSIVE_LOCKS_REQUIRED(g_cs_orphans) |
Erase all orphans announced by a peer (eg, after that peer disconnects) More... | |
void | EraseForBlock (const CBlock &block) LOCKS_EXCLUDED(g_cs_orphans) |
Erase all orphans included in or invalidated by a new block. More... | |
unsigned int | LimitOrphans (unsigned int max_orphans) EXCLUSIVE_LOCKS_REQUIRED(g_cs_orphans) |
Limit the orphanage to the given maximum. More... | |
void | AddChildrenToWorkSet (const CTransaction &tx, std::set< TxId > &orphan_work_set) const EXCLUSIVE_LOCKS_REQUIRED(g_cs_orphans) |
Add any orphans that list a particular tx as a parent into a peer's work set (ie orphans that may have found their final missing parent, and so should be reconsidered for the mempool) More... | |
size_t | Size () LOCKS_EXCLUDED( |
Return how many entries exist in the orphange. More... | |
Protected Types | |
using | OrphanMap = decltype(m_orphans) |
Protected Member Functions | |
std::map< TxId, OrphanTx > m_orphans | GUARDED_BY (g_cs_orphans) |
Map from txid to orphan transaction record. More... | |
std::map< COutPoint, std::set< OrphanMap ::iterator, IteratorComparator > > m_outpoint_to_orphan_it | GUARDED_BY (g_cs_orphans) |
Index from the parents' COutPoint into the m_orphans. More... | |
std::vector< OrphanMap::iterator > m_orphan_list | GUARDED_BY (g_cs_orphans) |
Orphan transactions in vector for quick random eviction. 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 22 of file txorphanage.h.
|
protected |
Definition at line 82 of file txorphanage.h.
void TxOrphanage::AddChildrenToWorkSet | ( | const CTransaction & | tx, |
std::set< TxId > & | orphan_work_set | ||
) | const |
Add any orphans that list a particular tx as a parent into a peer's work set (ie orphans that may have found their final missing parent, and so should be reconsidered for the mempool)
Definition at line 145 of file txorphanage.cpp.
bool TxOrphanage::AddTx | ( | const CTransactionRef & | tx, |
NodeId | peer | ||
) |
Add a new orphan transaction.
Definition at line 20 of file txorphanage.cpp.
void TxOrphanage::EraseForBlock | ( | const CBlock & | block | ) |
Erase all orphans included in or invalidated by a new block.
Definition at line 174 of file txorphanage.cpp.
void TxOrphanage::EraseForPeer | ( | NodeId | peer | ) |
Erase all orphans announced by a peer (eg, after that peer disconnects)
Definition at line 88 of file txorphanage.cpp.
int TxOrphanage::EraseTx | ( | const TxId & | txid | ) |
Erase an orphan by txid.
Definition at line 56 of file txorphanage.cpp.
std::pair< CTransactionRef, NodeId > TxOrphanage::GetTx | ( | const TxId & | txid | ) | const |
Get an orphan transaction and its originating peer (Transaction ref will be nullptr if not found)
Definition at line 164 of file txorphanage.cpp.
|
protected |
Map from txid to orphan transaction record.
Limited by -maxorphantx/DEFAULT_MAX_ORPHAN_TRANSACTIONS
|
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.
bool TxOrphanage::HaveTx | ( | const TxId & | txid | ) | const |
Check if we already have an orphan transaction.
Definition at line 159 of file txorphanage.cpp.
unsigned int TxOrphanage::LimitOrphans | ( | unsigned int | max_orphans | ) |
Limit the orphanage to the given maximum.
Definition at line 106 of file txorphanage.cpp.
|
inline |
Return how many entries exist in the orphange.
Definition at line 63 of file txorphanage.h.