diff options
author | Pieter Wuille <pieter.wuille@gmail.com> | 2014-12-23 23:50:21 +0100 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2015-01-07 13:11:49 +0100 |
commit | 3022e7df2a3f2c6e9869877c189c7e7cea7d7b54 (patch) | |
tree | e095513fcc403a0ed7a72ee394ee0ee816b70b4f /src | |
parent | 06fdf326d38b02efba0ebafa4be59b4ac062c092 (diff) | |
download | bitcoin-3022e7df2a3f2c6e9869877c189c7e7cea7d7b54.tar.xz |
Require sufficent priority for relay of free transactions
Rebased-From: 1c52aad540ec1370db60fd68fc3485413e3cb8e1
Github-Pull: #5535
Diffstat (limited to 'src')
-rw-r--r-- | src/init.cpp | 1 | ||||
-rw-r--r-- | src/main.cpp | 9 |
2 files changed, 8 insertions, 2 deletions
diff --git a/src/init.cpp b/src/init.cpp index 4374d60fe5..c5430c1f25 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=<n> " + strprintf(_("Continuously rate-limit free transactions to <n>*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=<n> " + strprintf(_("Limit size of signature cache to <n> entries (default: %u)"), 50000) + "\n"; } strUsage += " -minrelaytxfee=<amt> " + 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 c40a5e1672..cf2d07604f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1022,7 +1022,12 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa hash.ToString(), nFees, txMinFee), REJECT_INSUFFICIENTFEE, "insufficient fee"); - // Continuously rate-limit free (really, very-low-fee)transactions + // 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. if (fLimitFree && nFees < ::minRelayTxFee.GetFee(nSize)) @@ -1041,7 +1046,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; } |