From 9b2a04bd957a24bb64e7e8430520b6da7761bb20 Mon Sep 17 00:00:00 2001 From: Eirik Ogilvie-Wigley Date: Wed, 9 Oct 2019 13:42:46 -0600 Subject: [PATCH] Use tx cost rather than evictionWeight when checking mempool capacity --- src/mempoollimit.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/mempoollimit.cpp b/src/mempoollimit.cpp index d20e805a6..c04a90e41 100644 --- a/src/mempoollimit.cpp +++ b/src/mempoollimit.cpp @@ -124,12 +124,12 @@ void WeightedTxTree::remove(const uint256& txId) boost::optional WeightedTxTree::maybeDropRandom() { - int64_t totalPenaltyWeight = getTotalWeight().evictionWeight; - if (totalPenaltyWeight <= capacity) { + TxWeight totalTxWeight = getTotalWeight(); + if (totalTxWeight.cost <= capacity) { return boost::none; } - LogPrint("mempool", "Mempool cost limit exceeded (cost=%d, limit=%d)\n", totalPenaltyWeight, capacity); - int randomWeight = GetRand(totalPenaltyWeight); + LogPrint("mempool", "Mempool cost limit exceeded (cost=%d, limit=%d)\n", totalTxWeight.cost, capacity); + int randomWeight = GetRand(totalTxWeight.evictionWeight); WeightedTxInfo drop = txIdAndWeights[findByEvictionWeight(0, randomWeight)]; LogPrint("mempool", "Evicting transaction (txid=%s, cost=%d, evictionWeight=%d)\n", drop.txId.ToString(), drop.txWeight.cost, drop.txWeight.evictionWeight);