Add verbose boolean to getrawmempool

Also changes mempool to store CTxMemPoolEntries
to keep track of when they enter/exit the pool.
This commit is contained in:
Gavin Andresen
2013-11-11 17:35:14 +10:00
parent 0733c1bde6
commit 4d707d5120
12 changed files with 212 additions and 76 deletions

View File

@@ -12,6 +12,33 @@
/** Fake height value used in CCoins to signify they are only in the memory pool (since 0.8) */
static const unsigned int MEMPOOL_HEIGHT = 0x7FFFFFFF;
/*
* CTxMemPool stores these:
*/
class CTxMemPoolEntry
{
private:
CTransaction tx;
int64_t nFee; // Cached to avoid expensive parent-transaction lookups
size_t nTxSize; // ... and avoid recomputing tx size
int64_t nTime; // Local time when entering the mempool
double dPriority; // Priority when entering the mempool
unsigned int nHeight; // Chain height when entering the mempool
public:
CTxMemPoolEntry(const CTransaction& _tx, int64_t _nFee,
int64_t _nTime, double _dPriority, unsigned int _nHeight);
CTxMemPoolEntry();
CTxMemPoolEntry(const CTxMemPoolEntry& other);
const CTransaction& GetTx() const { return this->tx; }
double GetPriority(unsigned int currentHeight) const;
int64_t GetFee() const { return nFee; }
size_t GetTxSize() const { return nTxSize; }
int64_t GetTime() const { return nTime; }
unsigned int GetHeight() const { return nHeight; }
};
/*
* CTxMemPool stores valid-according-to-the-current-best-chain
* transactions that may be included in the next block.
@@ -30,7 +57,7 @@ private:
public:
mutable CCriticalSection cs;
std::map<uint256, CTransaction> mapTx;
std::map<uint256, CTxMemPoolEntry> mapTx;
std::map<COutPoint, CInPoint> mapNextTx;
CTxMemPool();
@@ -44,7 +71,7 @@ public:
void check(CCoinsViewCache *pcoins) const;
void setSanityCheck(bool _fSanityCheck) { fSanityCheck = _fSanityCheck; }
bool addUnchecked(const uint256& hash, const CTransaction &tx);
bool addUnchecked(const uint256& hash, const CTxMemPoolEntry &entry);
bool remove(const CTransaction &tx, bool fRecursive = false);
bool removeConflicts(const CTransaction &tx);
void clear();