Changeset View
Changeset View
Standalone View
Standalone View
src/txorphanage.h
Show All 35 Lines | public: | ||||
* Erase all orphans announced by a peer (eg, after that peer disconnects) | * Erase all orphans announced by a peer (eg, after that peer disconnects) | ||||
*/ | */ | ||||
void EraseForPeer(NodeId peer) EXCLUSIVE_LOCKS_REQUIRED(g_cs_orphans); | void EraseForPeer(NodeId peer) EXCLUSIVE_LOCKS_REQUIRED(g_cs_orphans); | ||||
/** Erase all orphans included in / invalidated by a new block */ | /** Erase all orphans included in / invalidated by a new block */ | ||||
void EraseForBlock(const CBlock &block) LOCKS_EXCLUDED(g_cs_orphans); | void EraseForBlock(const CBlock &block) LOCKS_EXCLUDED(g_cs_orphans); | ||||
/** Limit the orphanage to the given maximum */ | /** Limit the orphanage to the given maximum */ | ||||
unsigned int LimitOrphans(unsigned int nMaxOrphans) | unsigned int LimitOrphans(unsigned int max_orphans) | ||||
EXCLUSIVE_LOCKS_REQUIRED(g_cs_orphans); | EXCLUSIVE_LOCKS_REQUIRED(g_cs_orphans); | ||||
/** | /** | ||||
* Add any orphans that list a particular tx as a parent into a peer's work | * 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 | * set (ie orphans that may have found their final missing parent, and so | ||||
* should be reconsidered for the mempool) | * should be reconsidered for the mempool) | ||||
*/ | */ | ||||
void AddChildrenToWorkSet(const CTransaction &tx, | void AddChildrenToWorkSet(const CTransaction &tx, | ||||
std::set<TxId> &orphan_work_set) const | std::set<TxId> &orphan_work_set) const | ||||
EXCLUSIVE_LOCKS_REQUIRED(g_cs_orphans); | EXCLUSIVE_LOCKS_REQUIRED(g_cs_orphans); | ||||
protected: | protected: | ||||
struct COrphanTx { | struct OrphanTx { | ||||
CTransactionRef tx; | CTransactionRef tx; | ||||
NodeId fromPeer; | NodeId fromPeer; | ||||
int64_t nTimeExpire; | int64_t nTimeExpire; | ||||
size_t list_pos; | size_t list_pos; | ||||
}; | }; | ||||
/** | /** | ||||
* Map from txid to orphan transaction record. Limited by | * Map from txid to orphan transaction record. Limited by | ||||
* -maxorphantx/DEFAULT_MAX_ORPHAN_TRANSACTIONS | * -maxorphantx/DEFAULT_MAX_ORPHAN_TRANSACTIONS | ||||
*/ | */ | ||||
std::map<TxId, COrphanTx> mapOrphanTransactions GUARDED_BY(g_cs_orphans); | std::map<TxId, OrphanTx> m_orphans GUARDED_BY(g_cs_orphans); | ||||
using OrphanMap = decltype(mapOrphanTransactions); | using OrphanMap = decltype(m_orphans); | ||||
struct IteratorComparator { | struct IteratorComparator { | ||||
template <typename I> bool operator()(const I &a, const I &b) const { | template <typename I> bool operator()(const I &a, const I &b) const { | ||||
return &(*a) < &(*b); | return &(*a) < &(*b); | ||||
} | } | ||||
}; | }; | ||||
/** | /** | ||||
* Index from the parents' COutPoint into the mapOrphanTransactions. Used | * Index from the parents' COutPoint into the m_orphans. Used | ||||
* to remove orphan transactions from the mapOrphanTransactions | * to remove orphan transactions from the m_orphans | ||||
*/ | */ | ||||
std::map<COutPoint, std::set<OrphanMap ::iterator, IteratorComparator>> | std::map<COutPoint, std::set<OrphanMap ::iterator, IteratorComparator>> | ||||
mapOrphanTransactionsByPrev GUARDED_BY(g_cs_orphans); | m_outpoint_to_orphan_it GUARDED_BY(g_cs_orphans); | ||||
/** Orphan transactions in vector for quick random eviction */ | /** Orphan transactions in vector for quick random eviction */ | ||||
std::vector<OrphanMap::iterator> g_orphan_list GUARDED_BY(g_cs_orphans); | std::vector<OrphanMap::iterator> m_orphan_list GUARDED_BY(g_cs_orphans); | ||||
}; | }; | ||||
#endif // BITCOIN_TXORPHANAGE_H | #endif // BITCOIN_TXORPHANAGE_H |