Changeset View
Changeset View
Standalone View
Standalone View
src/txmempool.h
Show First 20 Lines • Show All 209 Lines • ▼ Show 20 Lines | struct update_lock_points { | ||||
explicit update_lock_points(const LockPoints &_lp) : lp(_lp) {} | explicit update_lock_points(const LockPoints &_lp) : lp(_lp) {} | ||||
void operator()(CTxMemPoolEntry &e) { e.UpdateLockPoints(lp); } | void operator()(CTxMemPoolEntry &e) { e.UpdateLockPoints(lp); } | ||||
private: | private: | ||||
const LockPoints &lp; | const LockPoints &lp; | ||||
}; | }; | ||||
// extracts a transaction hash from CTxMemPoolEntry or CTransactionRef | // extracts a transaction id from CTxMemPoolEntry or CTransactionRef | ||||
struct mempoolentry_txid { | struct mempoolentry_txid { | ||||
typedef TxId result_type; | typedef TxId result_type; | ||||
result_type operator()(const CTxMemPoolEntry &entry) const { | result_type operator()(const CTxMemPoolEntry &entry) const { | ||||
return entry.GetTx().GetId(); | return entry.GetTx().GetId(); | ||||
} | } | ||||
result_type operator()(const CTransactionRef &tx) const { | result_type operator()(const CTransactionRef &tx) const { | ||||
return tx->GetId(); | return tx->GetId(); | ||||
▲ Show 20 Lines • Show All 325 Lines • ▼ Show 20 Lines | public: | ||||
*/ | */ | ||||
mutable RecursiveMutex cs; | mutable RecursiveMutex cs; | ||||
indexed_transaction_set mapTx GUARDED_BY(cs); | indexed_transaction_set mapTx GUARDED_BY(cs); | ||||
typedef indexed_transaction_set::nth_index<0>::type::iterator txiter; | typedef indexed_transaction_set::nth_index<0>::type::iterator txiter; | ||||
//!< All tx hashes/entries in mapTx, in random order | //!< All tx hashes/entries in mapTx, in random order | ||||
std::vector<std::pair<TxHash, txiter>> vTxHashes; | std::vector<std::pair<TxHash, txiter>> vTxHashes; | ||||
struct CompareIteratorByHash { | struct CompareIteratorById { | ||||
bool operator()(const txiter &a, const txiter &b) const { | bool operator()(const txiter &a, const txiter &b) const { | ||||
return a->GetTx().GetId() < b->GetTx().GetId(); | return a->GetTx().GetId() < b->GetTx().GetId(); | ||||
} | } | ||||
}; | }; | ||||
typedef std::set<txiter, CompareIteratorByHash> setEntries; | typedef std::set<txiter, CompareIteratorById> setEntries; | ||||
const setEntries &GetMemPoolParents(txiter entry) const | const setEntries &GetMemPoolParents(txiter entry) const | ||||
EXCLUSIVE_LOCKS_REQUIRED(cs); | EXCLUSIVE_LOCKS_REQUIRED(cs); | ||||
const setEntries &GetMemPoolChildren(txiter entry) const | const setEntries &GetMemPoolChildren(txiter entry) const | ||||
EXCLUSIVE_LOCKS_REQUIRED(cs); | EXCLUSIVE_LOCKS_REQUIRED(cs); | ||||
uint64_t CalculateDescendantMaximum(txiter entry) const | uint64_t CalculateDescendantMaximum(txiter entry) const | ||||
EXCLUSIVE_LOCKS_REQUIRED(cs); | EXCLUSIVE_LOCKS_REQUIRED(cs); | ||||
private: | private: | ||||
typedef std::map<txiter, setEntries, CompareIteratorByHash> cacheMap; | typedef std::map<txiter, setEntries, CompareIteratorById> cacheMap; | ||||
struct TxLinks { | struct TxLinks { | ||||
setEntries parents; | setEntries parents; | ||||
setEntries children; | setEntries children; | ||||
}; | }; | ||||
typedef std::map<txiter, TxLinks, CompareIteratorByHash> txlinksMap; | typedef std::map<txiter, TxLinks, CompareIteratorById> txlinksMap; | ||||
txlinksMap mapLinks; | txlinksMap mapLinks; | ||||
void UpdateParent(txiter entry, txiter parent, bool add); | void UpdateParent(txiter entry, txiter parent, bool add); | ||||
void UpdateChild(txiter entry, txiter child, bool add); | void UpdateChild(txiter entry, txiter child, bool add); | ||||
std::vector<indexed_transaction_set::const_iterator> | std::vector<indexed_transaction_set::const_iterator> | ||||
GetSortedDepthAndScore() const EXCLUSIVE_LOCKS_REQUIRED(cs); | GetSortedDepthAndScore() const EXCLUSIVE_LOCKS_REQUIRED(cs); | ||||
▲ Show 20 Lines • Show All 397 Lines • Show Last 20 Lines |