Changeset View
Changeset View
Standalone View
Standalone View
src/txmempool.h
Show First 20 Lines • Show All 221 Lines • ▼ Show 20 Lines | struct update_lock_points { | ||||
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 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 152 Lines • ▼ Show 20 Lines | |||||
class SaltedTxidHasher { | class SaltedTxidHasher { | ||||
private: | private: | ||||
/** Salt */ | /** Salt */ | ||||
const uint64_t k0, k1; | const uint64_t k0, k1; | ||||
public: | public: | ||||
SaltedTxidHasher(); | SaltedTxidHasher(); | ||||
size_t operator()(const uint256 &txid) const { | size_t operator()(const TxId &txid) const { | ||||
return SipHashUint256(k0, k1, txid); | return SipHashUint256(k0, k1, txid); | ||||
} | } | ||||
}; | }; | ||||
typedef std::pair<double, Amount> TXModifier; | typedef std::pair<double, Amount> TXModifier; | ||||
/** | /** | ||||
* CTxMemPool stores valid-according-to-the-current-best-chain transactions that | * CTxMemPool stores valid-according-to-the-current-best-chain transactions that | ||||
▲ Show 20 Lines • Show All 233 Lines • ▼ Show 20 Lines | void removeForReorg(const Config &config, const CCoinsViewCache *pcoins, | ||||
EXCLUSIVE_LOCKS_REQUIRED(cs_main); | EXCLUSIVE_LOCKS_REQUIRED(cs_main); | ||||
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 TxId &txida, const TxId &txidb); | ||||
void queryHashes(std::vector<uint256> &vtxid) const; | 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. | ||||
*/ | */ | ||||
bool HasNoInputsOf(const CTransaction &tx) const; | bool HasNoInputsOf(const CTransaction &tx) const; | ||||
/** Affect CreateNewBlock prioritisation of transactions */ | /** Affect CreateNewBlock prioritisation of transactions */ | ||||
void PrioritiseTransaction(const uint256 &hash, double dPriorityDelta, | void PrioritiseTransaction(const TxId &txid, double dPriorityDelta, | ||||
const Amount nFeeDelta); | const Amount nFeeDelta); | ||||
void ApplyDeltas(const uint256 hash, double &dPriorityDelta, | void ApplyDeltas(const uint256 hash, double &dPriorityDelta, | ||||
Amount &nFeeDelta) const; | Amount &nFeeDelta) const; | ||||
void ClearPrioritisation(const uint256 hash); | void ClearPrioritisation(const uint256 hash); | ||||
public: | public: | ||||
/** | /** | ||||
* Remove a set of transactions from the mempool. If a transaction is in | * Remove a set of transactions from the mempool. If a transaction is in | ||||
▲ Show 20 Lines • Show All 76 Lines • ▼ Show 20 Lines | public: | ||||
* Reduce the size of the mempool by expiring and then trimming the mempool. | * Reduce the size of the mempool by expiring and then trimming the mempool. | ||||
*/ | */ | ||||
void LimitSize(size_t limit, unsigned long age); | void LimitSize(size_t limit, unsigned long age); | ||||
/** | /** | ||||
* 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 TxId &txid, size_t &ancestors, | ||||
size_t &descendants) const; | size_t &descendants) const; | ||||
/** @returns true if the mempool is fully loaded */ | /** @returns true if the mempool is fully loaded */ | ||||
bool IsLoaded() const; | bool IsLoaded() const; | ||||
/** Sets the current loaded state */ | /** Sets the current loaded state */ | ||||
void SetIsLoaded(bool loaded); | 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; | ||||
} | } | ||||
bool exists(uint256 hash) const { | bool exists(const TxId &txid) const { | ||||
LOCK(cs); | LOCK(cs); | ||||
return mapTx.count(hash) != 0; | return mapTx.count(txid) != 0; | ||||
} | } | ||||
CTransactionRef get(const uint256 &hash) const; | CTransactionRef get(const TxId &txid) const; | ||||
TxMempoolInfo info(const uint256 &hash) const; | TxMempoolInfo info(const TxId &txid) const; | ||||
std::vector<TxMempoolInfo> infoAll() const; | std::vector<TxMempoolInfo> infoAll() const; | ||||
CFeeRate estimateFee() const; | CFeeRate estimateFee() const; | ||||
size_t DynamicMemoryUsage() const; | size_t DynamicMemoryUsage() const; | ||||
boost::signals2::signal<void(CTransactionRef)> NotifyEntryAdded; | boost::signals2::signal<void(CTransactionRef)> NotifyEntryAdded; | ||||
boost::signals2::signal<void(CTransactionRef, MemPoolRemovalReason)> | boost::signals2::signal<void(CTransactionRef, MemPoolRemovalReason)> | ||||
▲ Show 20 Lines • Show All 208 Lines • Show Last 20 Lines |