Changeset View
Changeset View
Standalone View
Standalone View
src/policy/fees.cpp
Show First 20 Lines • Show All 454 Lines • ▼ Show 20 Lines | void CBlockPolicyEstimator::processBlock( | ||||
untrackedTxs = 0; | untrackedTxs = 0; | ||||
} | } | ||||
CFeeRate CBlockPolicyEstimator::estimateFee(int confTarget) { | CFeeRate CBlockPolicyEstimator::estimateFee(int confTarget) { | ||||
// Return failure if trying to analyze a target we're not tracking | // Return failure if trying to analyze a target we're not tracking | ||||
// It's not possible to get reasonable estimates for confTarget of 1 | // It's not possible to get reasonable estimates for confTarget of 1 | ||||
if (confTarget <= 1 || | if (confTarget <= 1 || | ||||
(unsigned int)confTarget > feeStats.GetMaxConfirms()) { | (unsigned int)confTarget > feeStats.GetMaxConfirms()) { | ||||
return CFeeRate(0); | return CFeeRate(Amount(0)); | ||||
} | } | ||||
double median = feeStats.EstimateMedianVal( | double median = feeStats.EstimateMedianVal( | ||||
confTarget, SUFFICIENT_FEETXS, MIN_SUCCESS_PCT, true, nBestSeenHeight); | confTarget, SUFFICIENT_FEETXS, MIN_SUCCESS_PCT, true, nBestSeenHeight); | ||||
if (median < 0) { | if (median < 0) { | ||||
return CFeeRate(0); | return CFeeRate(Amount(0)); | ||||
} | } | ||||
return CFeeRate(Amount(int64_t(median))); | return CFeeRate(Amount(int64_t(median))); | ||||
} | } | ||||
CFeeRate CBlockPolicyEstimator::estimateSmartFee(int confTarget, | CFeeRate CBlockPolicyEstimator::estimateSmartFee(int confTarget, | ||||
int *answerFoundAtTarget, | int *answerFoundAtTarget, | ||||
const CTxMemPool &pool) { | const CTxMemPool &pool) { | ||||
if (answerFoundAtTarget) { | if (answerFoundAtTarget) { | ||||
*answerFoundAtTarget = confTarget; | *answerFoundAtTarget = confTarget; | ||||
} | } | ||||
// Return failure if trying to analyze a target we're not tracking | // Return failure if trying to analyze a target we're not tracking | ||||
if (confTarget <= 0 || | if (confTarget <= 0 || | ||||
(unsigned int)confTarget > feeStats.GetMaxConfirms()) { | (unsigned int)confTarget > feeStats.GetMaxConfirms()) { | ||||
return CFeeRate(0); | return CFeeRate(Amount(0)); | ||||
} | } | ||||
// It's not possible to get reasonable estimates for confTarget of 1 | // It's not possible to get reasonable estimates for confTarget of 1 | ||||
if (confTarget == 1) { | if (confTarget == 1) { | ||||
confTarget = 2; | confTarget = 2; | ||||
} | } | ||||
double median = -1; | double median = -1; | ||||
Show All 9 Lines | CFeeRate CBlockPolicyEstimator::estimateSmartFee(int confTarget, | ||||
} | } | ||||
// If mempool is limiting txs , return at least the min feerate from the | // If mempool is limiting txs , return at least the min feerate from the | ||||
// mempool | // mempool | ||||
Amount minPoolFee = | Amount minPoolFee = | ||||
pool.GetMinFee(GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * | pool.GetMinFee(GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * | ||||
1000000) | 1000000) | ||||
.GetFeePerK(); | .GetFeePerK(); | ||||
if (minPoolFee > 0 && minPoolFee > int64_t(median)) { | if (minPoolFee > Amount(0) && minPoolFee > Amount(int64_t(median))) { | ||||
return CFeeRate(minPoolFee); | return CFeeRate(minPoolFee); | ||||
} | } | ||||
if (median < 0) { | if (median < 0) { | ||||
return CFeeRate(0); | return CFeeRate(Amount(0)); | ||||
} | } | ||||
return CFeeRate(Amount(int64_t(median))); | return CFeeRate(Amount(int64_t(median))); | ||||
} | } | ||||
double CBlockPolicyEstimator::estimatePriority(int confTarget) { | double CBlockPolicyEstimator::estimatePriority(int confTarget) { | ||||
return -1; | return -1; | ||||
} | } | ||||
double CBlockPolicyEstimator::estimateSmartPriority(int confTarget, | double CBlockPolicyEstimator::estimateSmartPriority(int confTarget, | ||||
int *answerFoundAtTarget, | int *answerFoundAtTarget, | ||||
const CTxMemPool &pool) { | const CTxMemPool &pool) { | ||||
if (answerFoundAtTarget) { | if (answerFoundAtTarget) { | ||||
*answerFoundAtTarget = confTarget; | *answerFoundAtTarget = confTarget; | ||||
} | } | ||||
// If mempool is limiting txs, no priority txs are allowed | // If mempool is limiting txs, no priority txs are allowed | ||||
Amount minPoolFee = | Amount minPoolFee = | ||||
pool.GetMinFee(GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * | pool.GetMinFee(GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * | ||||
1000000) | 1000000) | ||||
.GetFeePerK(); | .GetFeePerK(); | ||||
if (minPoolFee > 0) { | if (minPoolFee > Amount(0)) { | ||||
return double(INF_PRIORITY.GetSatoshis()); | return double(INF_PRIORITY.GetSatoshis()); | ||||
} | } | ||||
return -1; | return -1; | ||||
} | } | ||||
void CBlockPolicyEstimator::Write(CAutoFile &fileout) { | void CBlockPolicyEstimator::Write(CAutoFile &fileout) { | ||||
fileout << nBestSeenHeight; | fileout << nBestSeenHeight; | ||||
Show All 34 Lines |