Changeset View
Changeset View
Standalone View
Standalone View
src/validation.cpp
Show First 20 Lines • Show All 892 Lines • ▼ Show 20 Lines | // Check for conflicts with in-memory transactions | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
CTxMemPoolEntry entry(ptx, nFees, nAcceptTime, dPriority, | CTxMemPoolEntry entry(ptx, nFees, nAcceptTime, dPriority, | ||||
chainActive.Height(), inChainInputValue, | chainActive.Height(), inChainInputValue, | ||||
fSpendsCoinbase, nSigOpsCount, lp); | fSpendsCoinbase, nSigOpsCount, lp); | ||||
unsigned int nSize = entry.GetTxSize(); | unsigned int nSize = entry.GetTxSize(); | ||||
int64_t netUTXOs = tx.GetNetOutputs(); | |||||
Amount minAcceptableFee = ::minRelayTxFee.GetFee(nSize); | |||||
// Here we charge a small fee for the creation of UTXOs | |||||
// And provide a small rebate for consolidating old UTXOs | |||||
if (netUTXOs >= 0) { | |||||
// Charge a fee that should be approximately the cost of an | |||||
// input + output pair when a new UTXO is created. The assumption | |||||
// is that an input is roughly 3 * the size of an output s | |||||
minAcceptableFee += netUTXOs * config.GetExcessUTXOCharge(); | |||||
} else { | |||||
// Give a discount back for the approximate amount of space an input | |||||
// would take in the transaction. | |||||
// That is to say 75 of the UTXO charge. | |||||
minAcceptableFee -= 3 * netUTXOs * config.GetExcessUTXOCharge() / 4; | |||||
} | |||||
// Ensure the fee is above zero. | |||||
minAcceptableFee = std::max(Amount(0), minAcceptableFee); | |||||
// Check that the transaction doesn't have an excessive number of | // Check that the transaction doesn't have an excessive number of | ||||
// sigops, making it impossible to mine. Since the coinbase transaction | // sigops, making it impossible to mine. Since the coinbase transaction | ||||
// itself can contain sigops MAX_STANDARD_TX_SIGOPS is less than | // itself can contain sigops MAX_STANDARD_TX_SIGOPS is less than | ||||
// MAX_BLOCK_SIGOPS_PER_MB; we still consider this an invalid rather | // MAX_BLOCK_SIGOPS_PER_MB; we still consider this an invalid rather | ||||
// than merely non-standard transaction. | // than merely non-standard transaction. | ||||
if (nSigOpsCount > MAX_STANDARD_TX_SIGOPS) { | if (nSigOpsCount > MAX_STANDARD_TX_SIGOPS) { | ||||
return state.DoS(0, false, REJECT_NONSTANDARD, | return state.DoS(0, false, REJECT_NONSTANDARD, | ||||
"bad-txns-too-many-sigops", false, | "bad-txns-too-many-sigops", false, | ||||
strprintf("%d", nSigOpsCount)); | strprintf("%d", nSigOpsCount)); | ||||
} | } | ||||
Amount mempoolRejectFee = | Amount mempoolRejectFee = | ||||
pool.GetMinFee( | pool.GetMinFee( | ||||
gArgs.GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * | gArgs.GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * | ||||
1000000) | 1000000) | ||||
.GetFee(nSize); | .GetFee(nSize); | ||||
if (mempoolRejectFee > Amount(0) && nModifiedFees < mempoolRejectFee) { | if (mempoolRejectFee > Amount(0) && nModifiedFees < mempoolRejectFee) { | ||||
return state.DoS(0, false, REJECT_INSUFFICIENTFEE, | return state.DoS(0, false, REJECT_INSUFFICIENTFEE, | ||||
"mempool min fee not met", false, | "mempool min fee not met", false, | ||||
strprintf("%d < %d", nFees, mempoolRejectFee)); | strprintf("%d < %d", nFees, mempoolRejectFee)); | ||||
} | } | ||||
if (gArgs.GetBoolArg("-relaypriority", DEFAULT_RELAYPRIORITY) && | if (gArgs.GetBoolArg("-relaypriority", DEFAULT_RELAYPRIORITY) && | ||||
nModifiedFees < ::minRelayTxFee.GetFee(nSize) && | nModifiedFees <= minAcceptableFee && | ||||
!AllowFree(entry.GetPriority(chainActive.Height() + 1))) { | !AllowFree(entry.GetPriority(chainActive.Height() + 1))) { | ||||
// Require that free transactions have sufficient priority to be | // Require that free transactions have sufficient priority to be | ||||
// mined in the next block. | // mined in the next block. | ||||
return state.DoS(0, false, REJECT_INSUFFICIENTFEE, | return state.DoS(0, false, REJECT_INSUFFICIENTFEE, | ||||
"insufficient priority"); | "insufficient priority"); | ||||
} | } | ||||
// Continuously rate-limit free (really, very-low-fee) transactions. | // Continuously rate-limit free (really, very-low-fee) transactions. | ||||
▲ Show 20 Lines • Show All 4,520 Lines • Show Last 20 Lines |