Use fee deltas for determining mempool acceptance

(cherry picked from commit bitcoin/bitcoin@27fae3484c)

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 <daira@jacaranda.org>
This commit is contained in:
Suhas Daftuar 2015-12-02 09:37:18 -05:00 committed by Daira Emma Hopwood
parent e01ad01c94
commit cf3786f86b
1 changed files with 10 additions and 2 deletions

View File

@ -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;