Changeset View
Changeset View
Standalone View
Standalone View
src/txmempool.h
Show First 20 Lines • Show All 219 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 hash from CTxMemPoolEntry or CTransactionRef | ||||
struct mempoolentry_txid { | struct mempoolentry_txid { | ||||
typedef uint256 result_type; | typedef uint256 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 254 Lines • ▼ Show 20 Lines | private: | ||||
mutable int64_t lastRollingFeeUpdate; | mutable int64_t lastRollingFeeUpdate; | ||||
mutable bool blockSinceLastRollingFeeBump; | mutable bool blockSinceLastRollingFeeBump; | ||||
//!< minimum fee to get into the pool, decreases exponentially | //!< minimum fee to get into the pool, decreases exponentially | ||||
mutable double rollingMinimumFeeRate; | mutable double rollingMinimumFeeRate; | ||||
void trackPackageRemoved(const CFeeRate &rate) EXCLUSIVE_LOCKS_REQUIRED(cs); | void trackPackageRemoved(const CFeeRate &rate) EXCLUSIVE_LOCKS_REQUIRED(cs); | ||||
bool m_is_loaded GUARDED_BY(cs){false}; | |||||
public: | public: | ||||
// public only for testing | // public only for testing | ||||
static const int ROLLING_FEE_HALFLIFE = 60 * 60 * 12; | static const int ROLLING_FEE_HALFLIFE = 60 * 60 * 12; | ||||
typedef boost::multi_index_container< | typedef boost::multi_index_container< | ||||
CTxMemPoolEntry, boost::multi_index::indexed_by< | CTxMemPoolEntry, boost::multi_index::indexed_by< | ||||
// sorted by txid | // sorted by txid | ||||
boost::multi_index::hashed_unique< | boost::multi_index::hashed_unique< | ||||
▲ Show 20 Lines • Show All 133 Lines • ▼ Show 20 Lines | public: | ||||
void removeConflicts(const CTransaction &tx) EXCLUSIVE_LOCKS_REQUIRED(cs); | void removeConflicts(const CTransaction &tx) EXCLUSIVE_LOCKS_REQUIRED(cs); | ||||
void removeForBlock(const std::vector<CTransactionRef> &vtx, | void removeForBlock(const std::vector<CTransactionRef> &vtx, | ||||
unsigned int nBlockHeight); | unsigned int nBlockHeight); | ||||
void clear(); | void clear(); | ||||
// lock free | // lock free | ||||
void _clear() EXCLUSIVE_LOCKS_REQUIRED(cs); | void _clear() EXCLUSIVE_LOCKS_REQUIRED(cs); | ||||
bool CompareDepthAndScore(const uint256 &hasha, const uint256 &hashb); | bool CompareDepthAndScore(const uint256 &hasha, const uint256 &hashb); | ||||
void queryHashes(std::vector<uint256> &vtxid); | void queryHashes(std::vector<uint256> &vtxid) const; | ||||
bool isSpent(const COutPoint &outpoint) const; | bool isSpent(const COutPoint &outpoint) const; | ||||
unsigned int GetTransactionsUpdated() const; | unsigned int GetTransactionsUpdated() const; | ||||
void AddTransactionsUpdated(unsigned int n); | void AddTransactionsUpdated(unsigned int n); | ||||
/** | /** | ||||
* Check that none of this transactions inputs are in the mempool, and thus | * Check that none of this transactions inputs are in the mempool, and thus | ||||
* the tx is not dependent on other mempool transactions to be included in a | * the tx is not dependent on other mempool transactions to be included in a | ||||
* block. | * block. | ||||
*/ | */ | ||||
▲ Show 20 Lines • Show All 91 Lines • ▼ Show 20 Lines | public: | ||||
/** | /** | ||||
* Calculate the ancestor and descendant count for the given transaction. | * Calculate the ancestor and descendant count for the given transaction. | ||||
* The counts include the transaction itself. | * The counts include the transaction itself. | ||||
*/ | */ | ||||
void GetTransactionAncestry(const uint256 &txid, size_t &ancestors, | void GetTransactionAncestry(const uint256 &txid, size_t &ancestors, | ||||
size_t &descendants) const; | size_t &descendants) const; | ||||
/** @returns true if the mempool is fully loaded */ | |||||
bool IsLoaded() const; | |||||
/** Sets the current loaded state */ | |||||
void SetIsLoaded(bool loaded); | |||||
unsigned long size() const { | unsigned long size() const { | ||||
LOCK(cs); | LOCK(cs); | ||||
return mapTx.size(); | return mapTx.size(); | ||||
} | } | ||||
uint64_t GetTotalTxSize() const { | uint64_t GetTotalTxSize() const { | ||||
LOCK(cs); | LOCK(cs); | ||||
return totalTxSize; | return totalTxSize; | ||||
▲ Show 20 Lines • Show All 225 Lines • Show Last 20 Lines |