aboutsummaryrefslogtreecommitdiff
path: root/src/txmempool.cpp
diff options
context:
space:
mode:
authorJeff Garzik <jgarzik@bitpay.com>2014-08-06 23:58:19 -0400
committerJeff Garzik <jgarzik@bitpay.com>2014-08-14 12:34:38 -0400
commit6f2c26a457d279138d23d0f321edf55cd6b1f72f (patch)
treece209c55c8ede839f538481135bf6949523db5cc /src/txmempool.cpp
parent7accb7dbad6bef0c98dc436d164f27189294eaf5 (diff)
Closely track mempool byte total. Add "getmempoolinfo" RPC.
Goal: Gain live insight into the mempool. Groundwork for future work that caps mempool size.
Diffstat (limited to 'src/txmempool.cpp')
-rw-r--r--src/txmempool.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/txmempool.cpp b/src/txmempool.cpp
index 29924fff09..80cae68244 100644
--- a/src/txmempool.cpp
+++ b/src/txmempool.cpp
@@ -402,6 +402,7 @@ bool CTxMemPool::addUnchecked(const uint256& hash, const CTxMemPoolEntry &entry)
for (unsigned int i = 0; i < tx.vin.size(); i++)
mapNextTx[tx.vin[i].prevout] = CInPoint(&tx, i);
nTransactionsUpdated++;
+ totalTxSize += entry.GetTxSize();
}
return true;
}
@@ -426,6 +427,8 @@ void CTxMemPool::remove(const CTransaction &tx, std::list<CTransaction>& removed
removed.push_front(tx);
BOOST_FOREACH(const CTxIn& txin, tx.vin)
mapNextTx.erase(txin.prevout);
+
+ totalTxSize -= mapTx[hash].GetTxSize();
mapTx.erase(hash);
nTransactionsUpdated++;
}
@@ -477,6 +480,7 @@ void CTxMemPool::clear()
LOCK(cs);
mapTx.clear();
mapNextTx.clear();
+ totalTxSize = 0;
++nTransactionsUpdated;
}
@@ -487,9 +491,12 @@ void CTxMemPool::check(CCoinsViewCache *pcoins) const
LogPrint("mempool", "Checking mempool with %u transactions and %u inputs\n", (unsigned int)mapTx.size(), (unsigned int)mapNextTx.size());
+ uint64_t checkTotal = 0;
+
LOCK(cs);
for (std::map<uint256, CTxMemPoolEntry>::const_iterator it = mapTx.begin(); it != mapTx.end(); it++) {
unsigned int i = 0;
+ checkTotal += it->second.GetTxSize();
const CTransaction& tx = it->second.GetTx();
BOOST_FOREACH(const CTxIn &txin, tx.vin) {
// Check that every mempool transaction's inputs refer to available coins, or other mempool tx's.
@@ -518,6 +525,8 @@ void CTxMemPool::check(CCoinsViewCache *pcoins) const
assert(tx.vin.size() > it->second.n);
assert(it->first == it->second.ptx->vin[it->second.n].prevout);
}
+
+ assert(totalTxSize == checkTotal);
}
void CTxMemPool::queryHashes(vector<uint256>& vtxid)