|
|
@ -719,31 +719,24 @@ bool CheckTransaction(const CTransaction& tx, CValidationState &state) |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int64 GetMinFee(const CTransaction& tx, unsigned int nBlockSize, bool fAllowFree, enum GetMinFee_mode mode) |
|
|
|
int64 GetMinFee(const CTransaction& tx, bool fAllowFree, enum GetMinFee_mode mode) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// Base fee is either nMinTxFee or nMinRelayTxFee
|
|
|
|
// Base fee is either nMinTxFee or nMinRelayTxFee
|
|
|
|
int64 nBaseFee = (mode == GMF_RELAY) ? tx.nMinRelayTxFee : tx.nMinTxFee; |
|
|
|
int64 nBaseFee = (mode == GMF_RELAY) ? tx.nMinRelayTxFee : tx.nMinTxFee; |
|
|
|
|
|
|
|
|
|
|
|
unsigned int nBytes = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION); |
|
|
|
unsigned int nBytes = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION); |
|
|
|
unsigned int nNewBlockSize = nBlockSize + nBytes; |
|
|
|
|
|
|
|
int64 nMinFee = (1 + (int64)nBytes / 1000) * nBaseFee; |
|
|
|
int64 nMinFee = (1 + (int64)nBytes / 1000) * nBaseFee; |
|
|
|
|
|
|
|
|
|
|
|
if (fAllowFree) |
|
|
|
if (fAllowFree) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (nBlockSize == 1) |
|
|
|
// There is a free transaction area in blocks created by most miners,
|
|
|
|
{ |
|
|
|
// * If we are relaying we allow transactions up to DEFAULT_BLOCK_PRIORITY_SIZE - 1000
|
|
|
|
// Transactions under 10K are free
|
|
|
|
// to be considered to fall into this category
|
|
|
|
// (about 4500 BTC if made of 50 BTC inputs)
|
|
|
|
// * If we are creating a transaction we allow transactions up to DEFAULT_BLOCK_PRIORITY_SIZE - 17000
|
|
|
|
if (nBytes < 10000) |
|
|
|
// (= 10000) to be considered safe and assume they can likely make it into this section
|
|
|
|
nMinFee = 0; |
|
|
|
if (nBytes < (mode == GMF_SEND ? (DEFAULT_BLOCK_PRIORITY_SIZE - 17000) : (DEFAULT_BLOCK_PRIORITY_SIZE - 1000))) |
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// Free transaction area
|
|
|
|
|
|
|
|
if (nNewBlockSize < 27000) |
|
|
|
|
|
|
|
nMinFee = 0; |
|
|
|
nMinFee = 0; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// To limit dust spam, require base fee if any output is less than 0.01
|
|
|
|
// To limit dust spam, require base fee if any output is less than 0.01
|
|
|
|
if (nMinFee < nBaseFee) |
|
|
|
if (nMinFee < nBaseFee) |
|
|
@ -753,14 +746,6 @@ int64 GetMinFee(const CTransaction& tx, unsigned int nBlockSize, bool fAllowFree |
|
|
|
nMinFee = nBaseFee; |
|
|
|
nMinFee = nBaseFee; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Raise the price as the block approaches full
|
|
|
|
|
|
|
|
if (nBlockSize != 1 && nNewBlockSize >= MAX_BLOCK_SIZE_GEN/2) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (nNewBlockSize >= MAX_BLOCK_SIZE_GEN) |
|
|
|
|
|
|
|
return MAX_MONEY; |
|
|
|
|
|
|
|
nMinFee *= MAX_BLOCK_SIZE_GEN / (MAX_BLOCK_SIZE_GEN - nNewBlockSize); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!MoneyRange(nMinFee)) |
|
|
|
if (!MoneyRange(nMinFee)) |
|
|
|
nMinFee = MAX_MONEY; |
|
|
|
nMinFee = MAX_MONEY; |
|
|
|
return nMinFee; |
|
|
|
return nMinFee; |
|
|
@ -883,7 +868,7 @@ bool CTxMemPool::accept(CValidationState &state, CTransaction &tx, bool fLimitFr |
|
|
|
unsigned int nSize = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION); |
|
|
|
unsigned int nSize = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION); |
|
|
|
|
|
|
|
|
|
|
|
// Don't accept it if it can't get into a block
|
|
|
|
// Don't accept it if it can't get into a block
|
|
|
|
int64 txMinFee = GetMinFee(tx, 1000, true, GMF_RELAY); |
|
|
|
int64 txMinFee = GetMinFee(tx, true, GMF_RELAY); |
|
|
|
if (fLimitFree && nFees < txMinFee) |
|
|
|
if (fLimitFree && nFees < txMinFee) |
|
|
|
return error("CTxMemPool::accept() : not enough fees %s, %"PRI64d" < %"PRI64d, |
|
|
|
return error("CTxMemPool::accept() : not enough fees %s, %"PRI64d" < %"PRI64d, |
|
|
|
hash.ToString().c_str(), |
|
|
|
hash.ToString().c_str(), |
|
|
@ -4215,7 +4200,7 @@ CBlockTemplate* CreateNewBlock(CReserveKey& reservekey) |
|
|
|
|
|
|
|
|
|
|
|
// How much of the block should be dedicated to high-priority transactions,
|
|
|
|
// How much of the block should be dedicated to high-priority transactions,
|
|
|
|
// included regardless of the fees they pay
|
|
|
|
// included regardless of the fees they pay
|
|
|
|
unsigned int nBlockPrioritySize = GetArg("-blockprioritysize", 27000); |
|
|
|
unsigned int nBlockPrioritySize = GetArg("-blockprioritysize", DEFAULT_BLOCK_PRIORITY_SIZE); |
|
|
|
nBlockPrioritySize = std::min(nBlockMaxSize, nBlockPrioritySize); |
|
|
|
nBlockPrioritySize = std::min(nBlockMaxSize, nBlockPrioritySize); |
|
|
|
|
|
|
|
|
|
|
|
// Minimum block size you want to create; block will be filled with free transactions
|
|
|
|
// Minimum block size you want to create; block will be filled with free transactions
|
|
|
@ -4343,7 +4328,7 @@ CBlockTemplate* CreateNewBlock(CReserveKey& reservekey) |
|
|
|
// Prioritize by fee once past the priority size or we run out of high-priority
|
|
|
|
// Prioritize by fee once past the priority size or we run out of high-priority
|
|
|
|
// transactions:
|
|
|
|
// transactions:
|
|
|
|
if (!fSortedByFee && |
|
|
|
if (!fSortedByFee && |
|
|
|
((nBlockSize + nTxSize >= nBlockPrioritySize) || (dPriority < COIN * 144 / 250))) |
|
|
|
((nBlockSize + nTxSize >= nBlockPrioritySize) || !AllowFree(dPriority))) |
|
|
|
{ |
|
|
|
{ |
|
|
|
fSortedByFee = true; |
|
|
|
fSortedByFee = true; |
|
|
|
comparer = TxPriorityCompare(fSortedByFee); |
|
|
|
comparer = TxPriorityCompare(fSortedByFee); |
|
|
|