Changeset View
Changeset View
Standalone View
Standalone View
src/txmempool.h
Show First 20 Lines • Show All 88 Lines • ▼ Show 20 Lines | private: | ||||
// Information about descendants of this transaction that are in the | // Information about descendants of this transaction that are in the | ||||
// mempool; if we remove this transaction we must remove all of these | // mempool; if we remove this transaction we must remove all of these | ||||
// descendants as well. | // descendants as well. | ||||
//!< number of descendant transactions | //!< number of descendant transactions | ||||
uint64_t nCountWithDescendants; | uint64_t nCountWithDescendants; | ||||
//!< ... and size | //!< ... and size | ||||
uint64_t nSizeWithDescendants; | uint64_t nSizeWithDescendants; | ||||
//!< ... and virtual size | |||||
uint64_t nVirtualSizeWithDescendants; | |||||
//!< ... and total fees (all including us) | //!< ... and total fees (all including us) | ||||
Amount nModFeesWithDescendants; | Amount nModFeesWithDescendants; | ||||
// Analogous statistics for ancestor transactions | // Analogous statistics for ancestor transactions | ||||
uint64_t nCountWithAncestors; | uint64_t nCountWithAncestors; | ||||
uint64_t nSizeWithAncestors; | uint64_t nSizeWithAncestors; | ||||
uint64_t nVirtualSizeWithAncestors; | |||||
Amount nModFeesWithAncestors; | Amount nModFeesWithAncestors; | ||||
int64_t nSigOpCountWithAncestors; | int64_t nSigOpCountWithAncestors; | ||||
public: | public: | ||||
CTxMemPoolEntry(const CTransactionRef &_tx, const Amount _nFee, | CTxMemPoolEntry(const CTransactionRef &_tx, const Amount _nFee, | ||||
int64_t _nTime, unsigned int _entryHeight, | int64_t _nTime, unsigned int _entryHeight, | ||||
bool spendsCoinbase, int64_t _nSigOpCount, LockPoints lp); | bool spendsCoinbase, int64_t _nSigOpCount, LockPoints lp); | ||||
const CTransaction &GetTx() const { return *this->tx; } | const CTransaction &GetTx() const { return *this->tx; } | ||||
CTransactionRef GetSharedTx() const { return this->tx; } | CTransactionRef GetSharedTx() const { return this->tx; } | ||||
const Amount GetFee() const { return nFee; } | const Amount GetFee() const { return nFee; } | ||||
size_t GetTxSize() const { return nTxSize; } | size_t GetTxSize() const { return nTxSize; } | ||||
size_t GetTxVirtualSize() const; | |||||
int64_t GetTime() const { return nTime; } | int64_t GetTime() const { return nTime; } | ||||
unsigned int GetHeight() const { return entryHeight; } | unsigned int GetHeight() const { return entryHeight; } | ||||
int64_t GetSigOpCount() const { return sigOpCount; } | int64_t GetSigOpCount() const { return sigOpCount; } | ||||
Amount GetModifiedFee() const { return nFee + feeDelta; } | Amount GetModifiedFee() const { return nFee + feeDelta; } | ||||
size_t DynamicMemoryUsage() const { return nUsageSize; } | size_t DynamicMemoryUsage() const { return nUsageSize; } | ||||
const LockPoints &GetLockPoints() const { return lockPoints; } | const LockPoints &GetLockPoints() const { return lockPoints; } | ||||
// Adjusts the descendant state. | // Adjusts the descendant state. | ||||
void UpdateDescendantState(int64_t modifySize, Amount modifyFee, | void UpdateDescendantState(int64_t modifySize, int64_t modifyVirtualSize, | ||||
int64_t modifyCount); | Amount modifyFee, int64_t modifyCount); | ||||
// Adjusts the ancestor state | // Adjusts the ancestor state | ||||
void UpdateAncestorState(int64_t modifySize, Amount modifyFee, | void UpdateAncestorState(int64_t modifySize, int64_t modifyVirtualSize, | ||||
int64_t modifyCount, int modifySigOps); | Amount modifyFee, int64_t modifyCount, | ||||
int modifySigOps); | |||||
// Updates the fee delta used for mining priority score, and the | // Updates the fee delta used for mining priority score, and the | ||||
// modified fees with descendants. | // modified fees with descendants. | ||||
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 GetCountWithDescendants() const { return nCountWithDescendants; } | ||||
uint64_t GetSizeWithDescendants() const { return nSizeWithDescendants; } | uint64_t GetSizeWithDescendants() const { return nSizeWithDescendants; } | ||||
uint64_t GetVirtualSizeWithDescendants() const { | |||||
return nVirtualSizeWithDescendants; | |||||
} | |||||
Amount GetModFeesWithDescendants() const { return nModFeesWithDescendants; } | Amount GetModFeesWithDescendants() const { return nModFeesWithDescendants; } | ||||
bool GetSpendsCoinbase() const { return spendsCoinbase; } | bool GetSpendsCoinbase() const { return spendsCoinbase; } | ||||
uint64_t GetCountWithAncestors() const { return nCountWithAncestors; } | uint64_t GetCountWithAncestors() const { return nCountWithAncestors; } | ||||
uint64_t GetSizeWithAncestors() const { return nSizeWithAncestors; } | uint64_t GetSizeWithAncestors() const { return nSizeWithAncestors; } | ||||
uint64_t GetVirtualSizeWithAncestors() const { | |||||
return nVirtualSizeWithAncestors; | |||||
} | |||||
Amount GetModFeesWithAncestors() const { return nModFeesWithAncestors; } | Amount GetModFeesWithAncestors() const { return nModFeesWithAncestors; } | ||||
int64_t GetSigOpCountWithAncestors() const { | int64_t GetSigOpCountWithAncestors() const { | ||||
return nSigOpCountWithAncestors; | return nSigOpCountWithAncestors; | ||||
} | } | ||||
//!< Index in mempool's vTxHashes | //!< Index in mempool's vTxHashes | ||||
mutable size_t vTxHashesIdx; | mutable size_t vTxHashesIdx; | ||||
}; | }; | ||||
// Helpers for modifying CTxMemPool::mapTx, which is a boost multi_index. | // Helpers for modifying CTxMemPool::mapTx, which is a boost multi_index. | ||||
struct update_descendant_state { | struct update_descendant_state { | ||||
update_descendant_state(int64_t _modifySize, Amount _modifyFee, | update_descendant_state(int64_t _modifySize, int64_t _modifyVirtualSize, | ||||
int64_t _modifyCount) | Amount _modifyFee, int64_t _modifyCount) | ||||
: modifySize(_modifySize), modifyFee(_modifyFee), | : modifySize(_modifySize), modifyVirtualSize(_modifyVirtualSize), | ||||
modifyCount(_modifyCount) {} | modifyFee(_modifyFee), modifyCount(_modifyCount) {} | ||||
void operator()(CTxMemPoolEntry &e) { | void operator()(CTxMemPoolEntry &e) { | ||||
e.UpdateDescendantState(modifySize, modifyFee, modifyCount); | e.UpdateDescendantState(modifySize, modifyVirtualSize, modifyFee, | ||||
modifyCount); | |||||
} | } | ||||
private: | private: | ||||
int64_t modifySize; | int64_t modifySize; | ||||
int64_t modifyVirtualSize; | |||||
Amount modifyFee; | Amount modifyFee; | ||||
int64_t modifyCount; | int64_t modifyCount; | ||||
}; | }; | ||||
struct update_ancestor_state { | struct update_ancestor_state { | ||||
update_ancestor_state(int64_t _modifySize, Amount _modifyFee, | update_ancestor_state(int64_t _modifySize, int64_t _modifyVirtualSize, | ||||
int64_t _modifyCount, int64_t _modifySigOpCount) | Amount _modifyFee, int64_t _modifyCount, | ||||
: modifySize(_modifySize), modifyFee(_modifyFee), | int64_t _modifySigOpCount) | ||||
modifyCount(_modifyCount), modifySigOpCount(_modifySigOpCount) {} | : modifySize(_modifySize), modifyVirtualSize(_modifyVirtualSize), | ||||
modifyFee(_modifyFee), modifyCount(_modifyCount), | |||||
modifySigOpCount(_modifySigOpCount) {} | |||||
void operator()(CTxMemPoolEntry &e) { | void operator()(CTxMemPoolEntry &e) { | ||||
e.UpdateAncestorState(modifySize, modifyFee, modifyCount, | e.UpdateAncestorState(modifySize, modifyVirtualSize, modifyFee, | ||||
modifySigOpCount); | modifyCount, modifySigOpCount); | ||||
} | } | ||||
private: | private: | ||||
int64_t modifySize; | int64_t modifySize; | ||||
int64_t modifyVirtualSize; | |||||
Amount modifyFee; | Amount modifyFee; | ||||
int64_t modifyCount; | int64_t modifyCount; | ||||
int64_t modifySigOpCount; | int64_t modifySigOpCount; | ||||
}; | }; | ||||
struct update_fee_delta { | struct update_fee_delta { | ||||
explicit update_fee_delta(Amount _feeDelta) : feeDelta(_feeDelta) {} | explicit update_fee_delta(Amount _feeDelta) : feeDelta(_feeDelta) {} | ||||
▲ Show 20 Lines • Show All 781 Lines • Show Last 20 Lines |