From cf3786f86b563f3230f5f9920eb491159f8d4e02 Mon Sep 17 00:00:00 2001 From: Suhas Daftuar Date: Wed, 2 Dec 2015 09:37:18 -0500 Subject: [PATCH] Use fee deltas for determining mempool acceptance (cherry picked from commit bitcoin/bitcoin@27fae3484cdb21b0d24face833b966fce5926be5) Zcash: The change to tests is not included because we do not have `qa/rpc-tests/prioritize_transaction.py` (`prioritisetransaction.py` is very different). There is no point adding a test for this when it's immediately going to be broken by the removal of priority and "free" transactions. It will be up to the PRs that add the ZIP 317 changes to make sure that fee deltas are taken into account for transactions entering the mempool. Signed-off-by: Daira Emma Hopwood --- src/main.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 773f4a72c..7cb384c1c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1940,6 +1940,11 @@ bool AcceptToMemoryPool( CAmount nValueOut = tx.GetValueOut(); CAmount nFees = nValueIn-nValueOut; + // nModifiedFees includes any fee deltas from PrioritiseTransaction + CAmount nModifiedFees = nFees; + double nPriorityDummy = 0; + pool.ApplyDeltas(hash, nPriorityDummy, nModifiedFees); + double dPriority = view.GetPriority(tx, chainActive.Height()); // Keep track of transactions that spend a coinbase, which we re-scan @@ -1965,20 +1970,23 @@ bool AcceptToMemoryPool( // most DEFAULT_FEE. CAmount txMinFee = GetMinRelayFee(tx, pool, nSize, true); + + // txMinFee takes into account priority/fee deltas, so compare using + // nFees rather than nModifiedFees if (fLimitFree && nFees < txMinFee) { return state.DoS(0, false, REJECT_INSUFFICIENTFEE, "insufficient fee", false, strprintf("%d < %d", nFees, txMinFee)); } // Require that free transactions have sufficient priority to be mined in the next block. - if (GetBoolArg("-relaypriority", DEFAULT_RELAYPRIORITY) && nFees < ::minRelayTxFee.GetFeeForRelay(nSize) && !AllowFree(view.GetPriority(tx, chainActive.Height() + 1))) { + if (GetBoolArg("-relaypriority", DEFAULT_RELAYPRIORITY) && nModifiedFees < ::minRelayTxFee.GetFeeForRelay(nSize) && !AllowFree(view.GetPriority(tx, chainActive.Height() + 1))) { return state.DoS(0, false, REJECT_INSUFFICIENTFEE, "insufficient priority"); } // Continuously rate-limit free (really, very-low-fee) transactions // This mitigates 'penny-flooding' -- sending thousands of free transactions just to // be annoying or make others' transactions take longer to confirm. - if (fLimitFree && nFees < ::minRelayTxFee.GetFeeForRelay(nSize)) + if (fLimitFree && nModifiedFees < ::minRelayTxFee.GetFeeForRelay(nSize)) { static CCriticalSection csFreeLimiter; static double dFreeCount;