aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2011-05-26 00:38:20 +0200
committerPieter Wuille <pieter.wuille@gmail.com>2011-05-26 00:54:58 +0200
commit2bfda1be11a079f7b468c79d79a91ddb30369557 (patch)
tree989373a1154f39dc222b234a8acaf32684462bb8 /src
parente42677659800e1570ab5cd933ea923ec3dd63ff6 (diff)
Separate required fee for relaying and creation
Transactions created with the new minimal fee policy would not be relayed by the network. Therefore, we separate the minimal fee that is necessary to relay and to create, leaving the creation one at the old amount, for now.
Diffstat (limited to 'src')
-rw-r--r--src/main.cpp6
-rw-r--r--src/main.h17
2 files changed, 13 insertions, 10 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 68b6b4ee1b..f5f1ffd4ac 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -731,13 +731,13 @@ bool CTransaction::AcceptToMemoryPool(CTxDB& txdb, bool fCheckInputs, bool* pfMi
}
// Don't accept it if it can't get into a block
- if (nFees < GetMinFee(1000))
+ if (nFees < GetMinFee(1000, false, true))
return error("AcceptToMemoryPool() : not enough fees");
// Continuously rate-limit free transactions
// This mitigates 'penny-flooding' -- sending thousands of free transactions just to
// be annoying or make other's transactions take longer to confirm.
- if (nFees < MIN_TX_FEE)
+ if (nFees < MIN_RELAY_TX_FEE)
{
static CCriticalSection cs;
static double dFreeCount;
@@ -3329,7 +3329,7 @@ CBlock* CreateNewBlock(CReserveKey& reservekey)
// Transaction fee required depends on block size
bool fAllowFree = (nBlockSize + nTxSize < 4000 || CTransaction::AllowFree(dPriority));
- int64 nMinFee = tx.GetMinFee(nBlockSize, fAllowFree);
+ int64 nMinFee = tx.GetMinFee(nBlockSize, fAllowFree, true);
// Connecting shouldn't fail due to dependency on other memory pool transactions
// because we're already processing them in order of dependency
diff --git a/src/main.h b/src/main.h
index 92b73fe5ad..117a084756 100644
--- a/src/main.h
+++ b/src/main.h
@@ -29,7 +29,8 @@ static const unsigned int MAX_BLOCK_SIZE_GEN = MAX_BLOCK_SIZE/2;
static const int MAX_BLOCK_SIGOPS = MAX_BLOCK_SIZE/50;
static const int64 COIN = 100000000;
static const int64 CENT = 1000000;
-static const int64 MIN_TX_FEE = 50000;
+static const int64 MIN_TX_FEE = CENT;
+static const int64 MIN_RELAY_TX_FEE = 50000;
static const int64 MAX_MONEY = 21000000 * COIN;
inline bool MoneyRange(int64 nValue) { return (nValue >= 0 && nValue <= MAX_MONEY); }
static const int COINBASE_MATURITY = 100;
@@ -599,12 +600,14 @@ public:
return dPriority > COIN * 144 / 250;
}
- int64 GetMinFee(unsigned int nBlockSize=1, bool fAllowFree=true) const
+ int64 GetMinFee(unsigned int nBlockSize=1, bool fAllowFree=true, bool fForRelay=false) const
{
- // Base fee is 1 cent per kilobyte
+ // Base fee is either MIN_TX_FEE or MIN_RELAY_TX_FEE
+ int64 nBaseFee = fForRelay ? MIN_RELAY_TX_FEE : MIN_TX_FEE;
+
unsigned int nBytes = ::GetSerializeSize(*this, SER_NETWORK);
unsigned int nNewBlockSize = nBlockSize + nBytes;
- int64 nMinFee = (1 + (int64)nBytes / 1000) * MIN_TX_FEE;
+ int64 nMinFee = (1 + (int64)nBytes / 1000) * nBaseFee;
if (fAllowFree)
{
@@ -623,11 +626,11 @@ public:
}
}
- // To limit dust spam, require MIN_TX_FEE if any output is less than 0.01
- if (nMinFee < MIN_TX_FEE)
+ // To limit dust spam, require MIN_TX_FEE/MIN_RELAY_TX_FEE if any output is less than 0.01
+ if (nMinFee < nBaseFee)
BOOST_FOREACH(const CTxOut& txout, vout)
if (txout.nValue < CENT)
- nMinFee = MIN_TX_FEE;
+ nMinFee = nBaseFee;
// Raise the price as the block approaches full
if (nBlockSize != 1 && nNewBlockSize >= MAX_BLOCK_SIZE_GEN/2)