Use tx cost rather than evictionWeight when checking mempool capacity

This commit is contained in:
Eirik Ogilvie-Wigley 2019-10-09 13:42:46 -06:00
parent 2d9becbeb8
commit 9b2a04bd95
1 changed files with 4 additions and 4 deletions

View File

@ -124,12 +124,12 @@ void WeightedTxTree::remove(const uint256& txId)
boost::optional<uint256> 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);