Changeset View
Changeset View
Standalone View
Standalone View
src/txmempool.h
Show First 20 Lines • Show All 73 Lines • ▼ Show 20 Lines | struct CompareIteratorById { | ||||
} | } | ||||
}; | }; | ||||
/** \class CTxMemPoolEntry | /** \class CTxMemPoolEntry | ||||
* | * | ||||
* CTxMemPoolEntry stores data about the corresponding transaction, as well as | * CTxMemPoolEntry stores data about the corresponding transaction, as well as | ||||
* data about all in-mempool transactions that depend on the transaction | * data about all in-mempool transactions that depend on the transaction | ||||
* ("descendant" transactions). | * ("descendant" transactions). | ||||
* | |||||
* When a new entry is added to the mempool, we update the descendant state | |||||
* (nCountWithDescendants, nSizeWithDescendants, and nModFeesWithDescendants) | |||||
* for all ancestors of the newly added transaction. | |||||
*/ | */ | ||||
class CTxMemPoolEntry { | class CTxMemPoolEntry { | ||||
public: | public: | ||||
typedef std::reference_wrapper<const CTxMemPoolEntry> CTxMemPoolEntryRef; | typedef std::reference_wrapper<const CTxMemPoolEntry> CTxMemPoolEntryRef; | ||||
// two aliases, should the types ever diverge | // two aliases, should the types ever diverge | ||||
typedef std::set<CTxMemPoolEntryRef, CompareIteratorById> Parents; | typedef std::set<CTxMemPoolEntryRef, CompareIteratorById> Parents; | ||||
typedef std::set<CTxMemPoolEntryRef, CompareIteratorById> Children; | typedef std::set<CTxMemPoolEntryRef, CompareIteratorById> Children; | ||||
Show All 20 Lines | private: | ||||
//! Total sigChecks | //! Total sigChecks | ||||
const int64_t sigChecks; | const int64_t sigChecks; | ||||
//! Used for determining the priority of the transaction for mining in a | //! Used for determining the priority of the transaction for mining in a | ||||
//! block | //! block | ||||
Amount feeDelta{Amount::zero()}; | Amount feeDelta{Amount::zero()}; | ||||
//! Track the height and time at which tx was final | //! Track the height and time at which tx was final | ||||
LockPoints lockPoints; | LockPoints lockPoints; | ||||
// NOTE: | |||||
// The below members will stop being updated after Wellington activation, | |||||
// and should be removed in the release after Wellington is checkpointed. | |||||
// | |||||
// Information about descendants of this transaction that are in the | |||||
// mempool; if we remove this transaction we must remove all of these | |||||
// descendants as well. | |||||
//! number of descendant transactions | |||||
uint64_t nCountWithDescendants{1}; | |||||
//! ... and size | |||||
uint64_t nSizeWithDescendants; | |||||
//! ... and sichecks | |||||
int64_t nSigChecksWithDescendants; | |||||
// Analogous statistics for ancestor transactions | |||||
uint64_t nCountWithAncestors{1}; | |||||
uint64_t nSizeWithAncestors; | |||||
int64_t nSigChecksWithAncestors; | |||||
public: | public: | ||||
CTxMemPoolEntry(const CTransactionRef &_tx, const Amount fee, int64_t time, | CTxMemPoolEntry(const CTransactionRef &_tx, const Amount fee, int64_t time, | ||||
unsigned int entry_height, bool spends_coinbase, | unsigned int entry_height, bool spends_coinbase, | ||||
int64_t sigchecks, LockPoints lp); | int64_t sigchecks, LockPoints lp); | ||||
uint64_t GetEntryId() const { return entryId; } | uint64_t GetEntryId() const { return entryId; } | ||||
//! This should only be set by addUnchecked() before entry insertion into | //! This should only be set by addUnchecked() before entry insertion into | ||||
//! mempool | //! mempool | ||||
Show All 15 Lines | public: | ||||
size_t DynamicMemoryUsage() const { return nUsageSize; } | size_t DynamicMemoryUsage() const { return nUsageSize; } | ||||
const LockPoints &GetLockPoints() const { return lockPoints; } | const LockPoints &GetLockPoints() const { return lockPoints; } | ||||
// Updates the fee delta used for mining priority score | // Updates the fee delta used for mining priority score | ||||
void UpdateFeeDelta(Amount feeDelta); | void UpdateFeeDelta(Amount feeDelta); | ||||
// Update the LockPoints after a reorg | // Update the LockPoints after a reorg | ||||
void UpdateLockPoints(const LockPoints &lp); | void UpdateLockPoints(const LockPoints &lp); | ||||
uint64_t GetCountWithDescendants() const { return nCountWithDescendants; } | |||||
uint64_t GetSizeWithDescendants() const { return nSizeWithDescendants; } | |||||
uint64_t GetVirtualSizeWithDescendants() const; | |||||
int64_t GetSigChecksWithDescendants() const { | |||||
return nSigChecksWithDescendants; | |||||
} | |||||
bool GetSpendsCoinbase() const { return spendsCoinbase; } | bool GetSpendsCoinbase() const { return spendsCoinbase; } | ||||
uint64_t GetCountWithAncestors() const { return nCountWithAncestors; } | |||||
uint64_t GetSizeWithAncestors() const { return nSizeWithAncestors; } | |||||
uint64_t GetVirtualSizeWithAncestors() const; | |||||
int64_t GetSigChecksWithAncestors() const { | |||||
return nSigChecksWithAncestors; | |||||
} | |||||
const Parents &GetMemPoolParentsConst() const { return m_parents; } | const Parents &GetMemPoolParentsConst() const { return m_parents; } | ||||
const Children &GetMemPoolChildrenConst() const { return m_children; } | const Children &GetMemPoolChildrenConst() const { return m_children; } | ||||
Parents &GetMemPoolParents() const { return m_parents; } | Parents &GetMemPoolParents() const { return m_parents; } | ||||
Children &GetMemPoolChildren() const { return m_children; } | Children &GetMemPoolChildren() const { return m_children; } | ||||
}; | }; | ||||
// extracts a transaction id from CTxMemPoolEntry or CTransactionRef | // extracts a transaction id from CTxMemPoolEntry or CTransactionRef | ||||
struct mempoolentry_txid { | struct mempoolentry_txid { | ||||
▲ Show 20 Lines • Show All 714 Lines • Show Last 20 Lines |