Never consider transactions that pay the default fee to be free.
This commit is contained in:
parent
369fc78e0b
commit
cb64997216
|
@ -66,7 +66,7 @@ static const unsigned int MAX_REORG_LENGTH = COINBASE_MATURITY - 1;
|
||||||
static const bool DEFAULT_WHITELISTRELAY = true;
|
static const bool DEFAULT_WHITELISTRELAY = true;
|
||||||
/** Default for DEFAULT_WHITELISTFORCERELAY. */
|
/** Default for DEFAULT_WHITELISTFORCERELAY. */
|
||||||
static const bool DEFAULT_WHITELISTFORCERELAY = true;
|
static const bool DEFAULT_WHITELISTFORCERELAY = true;
|
||||||
/** Default for -minrelaytxfee, minimum relay fee for transactions */
|
/** Default for -minrelaytxfee, minimum relay fee for transactions in zatoshis/kB */
|
||||||
static const unsigned int DEFAULT_MIN_RELAY_TX_FEE = 100;
|
static const unsigned int DEFAULT_MIN_RELAY_TX_FEE = 100;
|
||||||
//! -maxtxfee default
|
//! -maxtxfee default
|
||||||
static const CAmount DEFAULT_TRANSACTION_MAXFEE = 0.1 * COIN;
|
static const CAmount DEFAULT_TRANSACTION_MAXFEE = 0.1 * COIN;
|
||||||
|
|
|
@ -64,9 +64,10 @@ public:
|
||||||
const CTransaction* ptx;
|
const CTransaction* ptx;
|
||||||
set<uint256> setDependsOn;
|
set<uint256> setDependsOn;
|
||||||
CFeeRate feeRate;
|
CFeeRate feeRate;
|
||||||
|
CAmount feePaid;
|
||||||
double dPriority;
|
double dPriority;
|
||||||
|
|
||||||
COrphan(const CTransaction* ptxIn) : ptx(ptxIn), feeRate(0), dPriority(0)
|
COrphan(const CTransaction* ptxIn) : ptx(ptxIn), feeRate(0), feePaid(0), dPriority(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -75,7 +76,7 @@ std::optional<uint64_t> last_block_num_txs;
|
||||||
std::optional<uint64_t> last_block_size;
|
std::optional<uint64_t> last_block_size;
|
||||||
|
|
||||||
// We want to sort transactions by priority and fee rate, so:
|
// We want to sort transactions by priority and fee rate, so:
|
||||||
typedef boost::tuple<double, CFeeRate, const CTransaction*> TxPriority;
|
typedef boost::tuple<double, CFeeRate, CAmount, const CTransaction*> TxPriority;
|
||||||
class TxPriorityCompare
|
class TxPriorityCompare
|
||||||
{
|
{
|
||||||
bool byFee;
|
bool byFee;
|
||||||
|
@ -491,15 +492,17 @@ CBlockTemplate* CreateNewBlock(const CChainParams& chainparams, const MinerAddre
|
||||||
uint256 hash = tx.GetHash();
|
uint256 hash = tx.GetHash();
|
||||||
mempool.ApplyDeltas(hash, dPriority, nTotalIn);
|
mempool.ApplyDeltas(hash, dPriority, nTotalIn);
|
||||||
|
|
||||||
CFeeRate feeRate(nTotalIn-tx.GetValueOut(), nTxSize);
|
CAmount feePaid = nTotalIn - tx.GetValueOut();
|
||||||
|
CFeeRate feeRate(feePaid, nTxSize);
|
||||||
|
|
||||||
if (porphan)
|
if (porphan)
|
||||||
{
|
{
|
||||||
porphan->dPriority = dPriority;
|
porphan->dPriority = dPriority;
|
||||||
porphan->feeRate = feeRate;
|
porphan->feeRate = feeRate;
|
||||||
|
porphan->feePaid = feePaid;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
vecPriority.push_back(TxPriority(dPriority, feeRate, &(mi->GetTx())));
|
vecPriority.push_back(TxPriority(dPriority, feeRate, feePaid, &(mi->GetTx())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -546,7 +549,8 @@ CBlockTemplate* CreateNewBlock(const CChainParams& chainparams, const MinerAddre
|
||||||
// Take highest priority transaction off the priority queue:
|
// Take highest priority transaction off the priority queue:
|
||||||
double dPriority = vecPriority.front().get<0>();
|
double dPriority = vecPriority.front().get<0>();
|
||||||
CFeeRate feeRate = vecPriority.front().get<1>();
|
CFeeRate feeRate = vecPriority.front().get<1>();
|
||||||
const CTransaction& tx = *(vecPriority.front().get<2>());
|
CAmount feePaid = vecPriority.front().get<2>();
|
||||||
|
const CTransaction& tx = *(vecPriority.front().get<3>());
|
||||||
const uint256& hash = tx.GetHash();
|
const uint256& hash = tx.GetHash();
|
||||||
|
|
||||||
std::pop_heap(vecPriority.begin(), vecPriority.end(), comparer);
|
std::pop_heap(vecPriority.begin(), vecPriority.end(), comparer);
|
||||||
|
@ -570,8 +574,17 @@ CBlockTemplate* CreateNewBlock(const CChainParams& chainparams, const MinerAddre
|
||||||
double dPriorityDelta = 0;
|
double dPriorityDelta = 0;
|
||||||
CAmount nFeeDelta = 0;
|
CAmount nFeeDelta = 0;
|
||||||
mempool.ApplyDeltas(hash, dPriorityDelta, nFeeDelta);
|
mempool.ApplyDeltas(hash, dPriorityDelta, nFeeDelta);
|
||||||
if (fSortedByFee && (dPriorityDelta <= 0) && (nFeeDelta <= 0) && (feeRate < ::minRelayTxFee) && (nBlockSize + nTxSize >= nBlockMinSize)) {
|
if (fSortedByFee &&
|
||||||
LogPrintf("%s: skipping free tx %s; already have minimum block size.", __func__, hash.GetHex());
|
(dPriorityDelta <= 0) &&
|
||||||
|
(nFeeDelta <= 0) &&
|
||||||
|
(feeRate < ::minRelayTxFee) &&
|
||||||
|
(feePaid < DEFAULT_FEE) &&
|
||||||
|
(nBlockSize + nTxSize >= nBlockMinSize))
|
||||||
|
{
|
||||||
|
LogPrintf(
|
||||||
|
"%s: skipping free tx %s (fee is %i; %s) with size %u, current block size is %u & already have minimum block size %u.",
|
||||||
|
__func__, hash.GetHex(),
|
||||||
|
feePaid, feeRate.ToString(), nTxSize, nBlockSize, nBlockMinSize);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -673,7 +686,7 @@ CBlockTemplate* CreateNewBlock(const CChainParams& chainparams, const MinerAddre
|
||||||
porphan->setDependsOn.erase(hash);
|
porphan->setDependsOn.erase(hash);
|
||||||
if (porphan->setDependsOn.empty())
|
if (porphan->setDependsOn.empty())
|
||||||
{
|
{
|
||||||
vecPriority.push_back(TxPriority(porphan->dPriority, porphan->feeRate, porphan->ptx));
|
vecPriority.push_back(TxPriority(porphan->dPriority, porphan->feeRate, porphan->feePaid, porphan->ptx));
|
||||||
std::push_heap(vecPriority.begin(), vecPriority.end(), comparer);
|
std::push_heap(vecPriority.begin(), vecPriority.end(), comparer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,10 @@ class CAutoFile;
|
||||||
|
|
||||||
inline double AllowFreeThreshold()
|
inline double AllowFreeThreshold()
|
||||||
{
|
{
|
||||||
|
// 144 is the number of Bitcoin blocks per day. This has not been updated for Zcash,
|
||||||
|
// as it would make it harder to get shielded transactions into blocks by lowering the
|
||||||
|
// threshold at which we switch from priority-based selection of transactions into
|
||||||
|
// blocks to fee-based selection.
|
||||||
return COIN * 144 / 250;
|
return COIN * 144 / 250;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue