Switch CTransaction storage in mempool to std::shared_ptr
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
#define BITCOIN_TXMEMPOOL_H
|
||||
|
||||
#include <list>
|
||||
#include <memory>
|
||||
#include <set>
|
||||
|
||||
#include "amount.h"
|
||||
@@ -75,7 +76,7 @@ class CTxMemPool;
|
||||
class CTxMemPoolEntry
|
||||
{
|
||||
private:
|
||||
CTransaction tx;
|
||||
std::shared_ptr<const CTransaction> tx;
|
||||
CAmount nFee; //!< Cached to avoid expensive parent-transaction lookups
|
||||
size_t nTxSize; //!< ... and avoid recomputing tx size
|
||||
size_t nModSize; //!< ... and modified size for priority
|
||||
@@ -112,7 +113,8 @@ public:
|
||||
unsigned int nSigOps, LockPoints lp);
|
||||
CTxMemPoolEntry(const CTxMemPoolEntry& other);
|
||||
|
||||
const CTransaction& GetTx() const { return this->tx; }
|
||||
const CTransaction& GetTx() const { return *this->tx; }
|
||||
std::shared_ptr<const CTransaction> GetSharedTx() const { return this->tx; }
|
||||
/**
|
||||
* Fast calculation of lower bound of current priority as update
|
||||
* from entry priority. Only inputs that were originally in-chain will age.
|
||||
@@ -307,6 +309,21 @@ struct ancestor_score {};
|
||||
|
||||
class CBlockPolicyEstimator;
|
||||
|
||||
/**
|
||||
* Information about a mempool transaction.
|
||||
*/
|
||||
struct TxMempoolInfo
|
||||
{
|
||||
/** The transaction itself */
|
||||
std::shared_ptr<const CTransaction> tx;
|
||||
|
||||
/** Time the transaction entered the mempool. */
|
||||
int64_t nTime;
|
||||
|
||||
/** Feerate of the transaction. */
|
||||
CFeeRate feeRate;
|
||||
};
|
||||
|
||||
/**
|
||||
* CTxMemPool stores valid-according-to-the-current-best-chain
|
||||
* transactions that may be included in the next block.
|
||||
@@ -464,6 +481,8 @@ private:
|
||||
void UpdateParent(txiter entry, txiter parent, bool add);
|
||||
void UpdateChild(txiter entry, txiter child, bool add);
|
||||
|
||||
std::vector<indexed_transaction_set::const_iterator> GetSortedDepthAndScore() const;
|
||||
|
||||
public:
|
||||
indirectmap<COutPoint, const CTransaction*> mapNextTx;
|
||||
std::map<uint256, std::pair<double, CAmount> > mapDeltas;
|
||||
@@ -589,8 +608,9 @@ public:
|
||||
}
|
||||
|
||||
bool lookup(uint256 hash, CTransaction& result) const;
|
||||
bool lookup(uint256 hash, CTransaction& result, int64_t& time) const;
|
||||
bool lookupFeeRate(const uint256& hash, CFeeRate& feeRate) const;
|
||||
std::shared_ptr<const CTransaction> get(const uint256& hash) const;
|
||||
TxMempoolInfo info(const uint256& hash) const;
|
||||
std::vector<TxMempoolInfo> infoAll() const;
|
||||
|
||||
/** Estimate fee rate needed to get into the next nBlocks
|
||||
* If no answer can be given at nBlocks, return an estimate
|
||||
|
||||
Reference in New Issue
Block a user