From 1c52aad540ec1370db60fd68fc3485413e3cb8e1 Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Tue, 23 Dec 2014 23:50:21 +0100 Subject: Require sufficent priority for relay of free transactions --- src/init.cpp | 1 + src/main.cpp | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/init.cpp b/src/init.cpp index a09caeea40..006f0a2a3a 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -324,6 +324,7 @@ std::string HelpMessage(HelpMessageMode mode) if (GetBoolArg("-help-debug", false)) { strUsage += " -limitfreerelay= " + strprintf(_("Continuously rate-limit free transactions to *1000 bytes per minute (default:%u)"), 15) + "\n"; + strUsage += " -relaypriority " + strprintf(_("Require high priority for relaying free or low-fee transactions (default:%u)"), 1) + "\n"; strUsage += " -maxsigcachesize= " + strprintf(_("Limit size of signature cache to entries (default: %u)"), 50000) + "\n"; } strUsage += " -minrelaytxfee= " + strprintf(_("Fees (in BTC/Kb) smaller than this are considered zero fee for relaying (default: %s)"), FormatMoney(::minRelayTxFee.GetFeePerK())) + "\n"; diff --git a/src/main.cpp b/src/main.cpp index 2410230ef4..011189544c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1029,6 +1029,11 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa hash.ToString(), nFees, txMinFee), REJECT_INSUFFICIENTFEE, "insufficient fee"); + // Require that free transactions have sufficient priority to be mined in the next block. + if (GetBoolArg("-relaypriority", true) && nFees < ::minRelayTxFee.GetFee(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. @@ -1048,7 +1053,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa // At default rate it would take over a month to fill 1GB if (dFreeCount >= GetArg("-limitfreerelay", 15)*10*1000) return state.DoS(0, error("AcceptToMemoryPool : free transaction rejected by rate limiter"), - REJECT_INSUFFICIENTFEE, "insufficient priority"); + REJECT_INSUFFICIENTFEE, "rate limited free transaction"); LogPrint("mempool", "Rate limit dFreeCount: %g => %g\n", dFreeCount, dFreeCount+nSize); dFreeCount += nSize; } -- cgit v1.2.3