|
|
@ -48,6 +48,11 @@ bool fBenchmark = false; |
|
|
|
bool fTxIndex = false; |
|
|
|
bool fTxIndex = false; |
|
|
|
unsigned int nCoinCacheSize = 5000; |
|
|
|
unsigned int nCoinCacheSize = 5000; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** Fees smaller than this (in satoshi) are considered zero fee (for transaction creation) */ |
|
|
|
|
|
|
|
int64 CTransaction::nMinTxFee = 10000; // Override with -mintxfee
|
|
|
|
|
|
|
|
/** Fees smaller than this (in satoshi) are considered zero fee (for relaying) */ |
|
|
|
|
|
|
|
int64 CTransaction::nMinRelayTxFee = 10000; |
|
|
|
|
|
|
|
|
|
|
|
CMedianFilter<int> cPeerBlockCounts(8, 0); // Amount of blocks that other nodes claim to have
|
|
|
|
CMedianFilter<int> cPeerBlockCounts(8, 0); // Amount of blocks that other nodes claim to have
|
|
|
|
|
|
|
|
|
|
|
|
map<uint256, CBlock*> mapOrphanBlocks; |
|
|
|
map<uint256, CBlock*> mapOrphanBlocks; |
|
|
@ -352,9 +357,22 @@ unsigned int LimitOrphanTxSize(unsigned int nMaxOrphans) |
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// CTransaction
|
|
|
|
// CTransaction / CTxOut
|
|
|
|
//
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool CTxOut::IsDust() const |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// "Dust" is defined in terms of CTransaction::nMinRelayTxFee,
|
|
|
|
|
|
|
|
// which has units satoshis-per-kilobyte.
|
|
|
|
|
|
|
|
// If you'd pay more than 1/3 in fees
|
|
|
|
|
|
|
|
// to spend something, then we consider it dust.
|
|
|
|
|
|
|
|
// A typical txout is 33 bytes big, and will
|
|
|
|
|
|
|
|
// need a CTxIn of at least 148 bytes to spend,
|
|
|
|
|
|
|
|
// so dust is a txout less than 54 uBTC
|
|
|
|
|
|
|
|
// (5430 satoshis) with default nMinRelayTxFee
|
|
|
|
|
|
|
|
return ((nValue*1000)/(3*((int)GetSerializeSize(SER_DISK,0)+148)) < CTransaction::nMinRelayTxFee); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool CTransaction::IsStandard() const |
|
|
|
bool CTransaction::IsStandard() const |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (nVersion > CTransaction::CURRENT_VERSION) |
|
|
|
if (nVersion > CTransaction::CURRENT_VERSION) |
|
|
@ -574,8 +592,8 @@ bool CTransaction::CheckTransaction(CValidationState &state) const |
|
|
|
int64 CTransaction::GetMinFee(unsigned int nBlockSize, bool fAllowFree, |
|
|
|
int64 CTransaction::GetMinFee(unsigned int nBlockSize, bool fAllowFree, |
|
|
|
enum GetMinFee_mode mode) const |
|
|
|
enum GetMinFee_mode mode) const |
|
|
|
{ |
|
|
|
{ |
|
|
|
// Base fee is either MIN_TX_FEE or MIN_RELAY_TX_FEE
|
|
|
|
// Base fee is either nMinTxFee or nMinRelayTxFee
|
|
|
|
int64 nBaseFee = (mode == GMF_RELAY) ? MIN_RELAY_TX_FEE : MIN_TX_FEE; |
|
|
|
int64 nBaseFee = (mode == GMF_RELAY) ? nMinRelayTxFee : nMinTxFee; |
|
|
|
|
|
|
|
|
|
|
|
unsigned int nBytes = ::GetSerializeSize(*this, SER_NETWORK, PROTOCOL_VERSION); |
|
|
|
unsigned int nBytes = ::GetSerializeSize(*this, SER_NETWORK, PROTOCOL_VERSION); |
|
|
|
unsigned int nNewBlockSize = nBlockSize + nBytes; |
|
|
|
unsigned int nNewBlockSize = nBlockSize + nBytes; |
|
|
@ -598,7 +616,7 @@ int64 CTransaction::GetMinFee(unsigned int nBlockSize, bool fAllowFree, |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// To limit dust spam, require MIN_TX_FEE/MIN_RELAY_TX_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) |
|
|
|
{ |
|
|
|
{ |
|
|
|
BOOST_FOREACH(const CTxOut& txout, vout) |
|
|
|
BOOST_FOREACH(const CTxOut& txout, vout) |
|
|
@ -746,7 +764,7 @@ bool CTxMemPool::accept(CValidationState &state, CTransaction &tx, bool fCheckIn |
|
|
|
// Continuously rate-limit free transactions
|
|
|
|
// Continuously rate-limit free transactions
|
|
|
|
// This mitigates 'penny-flooding' -- sending thousands of free transactions just to
|
|
|
|
// This mitigates 'penny-flooding' -- sending thousands of free transactions just to
|
|
|
|
// be annoying or make others' transactions take longer to confirm.
|
|
|
|
// be annoying or make others' transactions take longer to confirm.
|
|
|
|
if (fLimitFree && nFees < MIN_RELAY_TX_FEE) |
|
|
|
if (fLimitFree && nFees < CTransaction::nMinRelayTxFee) |
|
|
|
{ |
|
|
|
{ |
|
|
|
static double dFreeCount; |
|
|
|
static double dFreeCount; |
|
|
|
static int64 nLastTime; |
|
|
|
static int64 nLastTime; |
|
|
@ -4184,15 +4202,6 @@ CBlockTemplate* CreateNewBlock(CReserveKey& reservekey) |
|
|
|
unsigned int nBlockMinSize = GetArg("-blockminsize", 0); |
|
|
|
unsigned int nBlockMinSize = GetArg("-blockminsize", 0); |
|
|
|
nBlockMinSize = std::min(nBlockMaxSize, nBlockMinSize); |
|
|
|
nBlockMinSize = std::min(nBlockMaxSize, nBlockMinSize); |
|
|
|
|
|
|
|
|
|
|
|
// Fee-per-kilobyte amount considered the same as "free"
|
|
|
|
|
|
|
|
// Be careful setting this: if you set it to zero then
|
|
|
|
|
|
|
|
// a transaction spammer can cheaply fill blocks using
|
|
|
|
|
|
|
|
// 1-satoshi-fee transactions. It should be set above the real
|
|
|
|
|
|
|
|
// cost to you of processing a transaction.
|
|
|
|
|
|
|
|
int64 nMinTxFee = MIN_TX_FEE; |
|
|
|
|
|
|
|
if (mapArgs.count("-mintxfee")) |
|
|
|
|
|
|
|
ParseMoney(mapArgs["-mintxfee"], nMinTxFee); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Collect memory pool transactions into the block
|
|
|
|
// Collect memory pool transactions into the block
|
|
|
|
int64 nFees = 0; |
|
|
|
int64 nFees = 0; |
|
|
|
{ |
|
|
|
{ |
|
|
@ -4310,7 +4319,7 @@ CBlockTemplate* CreateNewBlock(CReserveKey& reservekey) |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
|
|
|
|
|
|
|
|
// Skip free transactions if we're past the minimum block size:
|
|
|
|
// Skip free transactions if we're past the minimum block size:
|
|
|
|
if (fSortedByFee && (dFeePerKb < nMinTxFee) && (nBlockSize + nTxSize >= nBlockMinSize)) |
|
|
|
if (fSortedByFee && (dFeePerKb < CTransaction::nMinTxFee) && (nBlockSize + nTxSize >= nBlockMinSize)) |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
|
|
|
|
|
|
|
|
// 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
|
|
|
|