aboutsummaryrefslogtreecommitdiff
path: root/src/txmempool.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/txmempool.h')
-rw-r--r--src/txmempool.h29
1 files changed, 24 insertions, 5 deletions
diff --git a/src/txmempool.h b/src/txmempool.h
index 3cf84159cc..f0e9b2e2c6 100644
--- a/src/txmempool.h
+++ b/src/txmempool.h
@@ -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.
@@ -308,6 +310,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;
@@ -588,9 +607,9 @@ public:
return (mapTx.count(hash) != 0);
}
- 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