aboutsummaryrefslogtreecommitdiff
path: root/src/txmempool.h
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2016-05-30 17:06:24 +0200
committerPieter Wuille <pieter.wuille@gmail.com>2016-06-05 00:31:43 +0200
commit8d39d7a2cf1559e0ba40681b0ab90f13ea6c0618 (patch)
treefa9d8274ff2d42f67b06f107b37b4f2f722a84c3 /src/txmempool.h
parent1b9e6d3c1a0f0e7eeff5ddb2e0386911fe9ab2b6 (diff)
downloadbitcoin-8d39d7a2cf1559e0ba40681b0ab90f13ea6c0618.tar.xz
Switch CTransaction storage in mempool to std::shared_ptr
Diffstat (limited to 'src/txmempool.h')
-rw-r--r--src/txmempool.h28
1 files changed, 24 insertions, 4 deletions
diff --git a/src/txmempool.h b/src/txmempool.h
index 3cf84159cc..2f407fe008 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;
@@ -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