mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-18 22:35:39 +01:00
Closely track mempool byte total. Add "getmempoolinfo" RPC.
Goal: Gain live insight into the mempool. Groundwork for future work that caps mempool size.
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user