|
|
@ -4,6 +4,7 @@ |
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
|
|
|
|
|
|
|
|
#include "policy/fees.h" |
|
|
|
#include "policy/fees.h" |
|
|
|
|
|
|
|
#include "policy/policy.h" |
|
|
|
|
|
|
|
|
|
|
|
#include "amount.h" |
|
|
|
#include "amount.h" |
|
|
|
#include "primitives/transaction.h" |
|
|
|
#include "primitives/transaction.h" |
|
|
@ -504,7 +505,7 @@ CFeeRate CBlockPolicyEstimator::estimateFee(int confTarget) |
|
|
|
return CFeeRate(median); |
|
|
|
return CFeeRate(median); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
CFeeRate CBlockPolicyEstimator::estimateSmartFee(int confTarget, int *answerFoundAtTarget) |
|
|
|
CFeeRate CBlockPolicyEstimator::estimateSmartFee(int confTarget, int *answerFoundAtTarget, const CTxMemPool *pool) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (answerFoundAtTarget) |
|
|
|
if (answerFoundAtTarget) |
|
|
|
*answerFoundAtTarget = confTarget; |
|
|
|
*answerFoundAtTarget = confTarget; |
|
|
@ -520,6 +521,11 @@ CFeeRate CBlockPolicyEstimator::estimateSmartFee(int confTarget, int *answerFoun |
|
|
|
if (answerFoundAtTarget) |
|
|
|
if (answerFoundAtTarget) |
|
|
|
*answerFoundAtTarget = confTarget - 1; |
|
|
|
*answerFoundAtTarget = confTarget - 1; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// If mempool is limiting txs , return at least the min fee from the mempool
|
|
|
|
|
|
|
|
CAmount minPoolFee = pool->GetMinFee(GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000).GetFeePerK(); |
|
|
|
|
|
|
|
if (minPoolFee > 0 && minPoolFee > median) |
|
|
|
|
|
|
|
return CFeeRate(minPoolFee); |
|
|
|
|
|
|
|
|
|
|
|
if (median < 0) |
|
|
|
if (median < 0) |
|
|
|
return CFeeRate(0); |
|
|
|
return CFeeRate(0); |
|
|
|
|
|
|
|
|
|
|
@ -535,7 +541,7 @@ double CBlockPolicyEstimator::estimatePriority(int confTarget) |
|
|
|
return priStats.EstimateMedianVal(confTarget, SUFFICIENT_PRITXS, MIN_SUCCESS_PCT, true, nBestSeenHeight); |
|
|
|
return priStats.EstimateMedianVal(confTarget, SUFFICIENT_PRITXS, MIN_SUCCESS_PCT, true, nBestSeenHeight); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
double CBlockPolicyEstimator::estimateSmartPriority(int confTarget, int *answerFoundAtTarget) |
|
|
|
double CBlockPolicyEstimator::estimateSmartPriority(int confTarget, int *answerFoundAtTarget, const CTxMemPool *pool) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (answerFoundAtTarget) |
|
|
|
if (answerFoundAtTarget) |
|
|
|
*answerFoundAtTarget = confTarget; |
|
|
|
*answerFoundAtTarget = confTarget; |
|
|
@ -543,6 +549,11 @@ double CBlockPolicyEstimator::estimateSmartPriority(int confTarget, int *answerF |
|
|
|
if (confTarget <= 0 || (unsigned int)confTarget > priStats.GetMaxConfirms()) |
|
|
|
if (confTarget <= 0 || (unsigned int)confTarget > priStats.GetMaxConfirms()) |
|
|
|
return -1; |
|
|
|
return -1; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// If mempool is limiting txs, no priority txs are allowed
|
|
|
|
|
|
|
|
CAmount minPoolFee = pool->GetMinFee(GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000).GetFeePerK(); |
|
|
|
|
|
|
|
if (minPoolFee > 0) |
|
|
|
|
|
|
|
return INF_PRIORITY; |
|
|
|
|
|
|
|
|
|
|
|
double median = -1; |
|
|
|
double median = -1; |
|
|
|
while (median < 0 && (unsigned int)confTarget <= priStats.GetMaxConfirms()) { |
|
|
|
while (median < 0 && (unsigned int)confTarget <= priStats.GetMaxConfirms()) { |
|
|
|
median = priStats.EstimateMedianVal(confTarget++, SUFFICIENT_PRITXS, MIN_SUCCESS_PCT, true, nBestSeenHeight); |
|
|
|
median = priStats.EstimateMedianVal(confTarget++, SUFFICIENT_PRITXS, MIN_SUCCESS_PCT, true, nBestSeenHeight); |
|
|
@ -551,6 +562,7 @@ double CBlockPolicyEstimator::estimateSmartPriority(int confTarget, int *answerF |
|
|
|
if (answerFoundAtTarget) |
|
|
|
if (answerFoundAtTarget) |
|
|
|
*answerFoundAtTarget = confTarget - 1; |
|
|
|
*answerFoundAtTarget = confTarget - 1; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return median; |
|
|
|
return median; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|