5 #ifndef BITCOIN_TXORPHANAGE_H
6 #define BITCOIN_TXORPHANAGE_H
35 std::pair<CTransactionRef, NodeId>
GetTx(
const TxId &txid)
const
59 std::set<TxId> &orphan_work_set)
const
65 return m_orphans.size();
85 template <
typename I>
bool operator()(
const I &a,
const I &b)
const {
94 std::map<COutPoint, std::set<OrphanMap ::iterator, IteratorComparator>>
The basic transaction that is broadcasted on the network and contained in blocks.
A class to track orphan transactions (failed on TX_MISSING_INPUTS) Since we cannot distinguish orphan...
decltype(m_orphans) OrphanMap
bool HaveTx(const TxId &txid) const LOCKS_EXCLUDED(g_cs_orphans)
Check if we already have an orphan transaction.
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)
size_t Size() LOCKS_EXCLUDED(
Return how many entries exist in the orphange.
void EraseForBlock(const CBlock &block) LOCKS_EXCLUDED(g_cs_orphans)
Erase all orphans included in or invalidated by a new block.
std::map< TxId, OrphanTx > m_orphans GUARDED_BY(g_cs_orphans)
Map from txid to orphan transaction record.
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.
void EraseForPeer(NodeId peer) EXCLUSIVE_LOCKS_REQUIRED(g_cs_orphans)
Erase all orphans announced by a peer (eg, after that peer disconnects)
std::vector< OrphanMap::iterator > m_orphan_list GUARDED_BY(g_cs_orphans)
Orphan transactions in vector for quick random eviction.
bool AddTx(const CTransactionRef &tx, NodeId peer) EXCLUSIVE_LOCKS_REQUIRED(g_cs_orphans)
Add a new orphan transaction.
unsigned int LimitOrphans(unsigned int max_orphans) EXCLUSIVE_LOCKS_REQUIRED(g_cs_orphans)
Limit the orphanage to the given maximum.
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 hav...
int EraseTx(const TxId &txid) EXCLUSIVE_LOCKS_REQUIRED(g_cs_orphans)
Erase an orphan by txid.
std::shared_ptr< const CTransaction > CTransactionRef
A TxId is the identifier of a transaction.
bool operator()(const I &a, const I &b) const
#define EXCLUSIVE_LOCKS_REQUIRED(...)
#define LOCKS_EXCLUDED(...)
RecursiveMutex g_cs_orphans
Guards orphan transactions and extra txs for compact blocks.