mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-19 23:03:45 +01:00
Remove the remaining fee estimation globals
This moves the CBlockPolicyEstimator to the NodeContext, which get rids of two globals and allows us to conditionally create the CBlockPolicyEstimator (and to remove a circular dep). Signed-off-by: Antoine Poinsot <darosior@protonmail.com>
This commit is contained in:
@@ -1059,7 +1059,10 @@ static RPCHelpMan estimatesmartfee()
|
||||
{
|
||||
RPCTypeCheck(request.params, {UniValue::VNUM, UniValue::VSTR});
|
||||
RPCTypeCheckArgument(request.params[0], UniValue::VNUM);
|
||||
unsigned int max_target = ::feeEstimator.HighestTargetTracked(FeeEstimateHorizon::LONG_HALFLIFE);
|
||||
|
||||
CBlockPolicyEstimator& fee_estimator = EnsureFeeEstimator(request.context);
|
||||
|
||||
unsigned int max_target = fee_estimator.HighestTargetTracked(FeeEstimateHorizon::LONG_HALFLIFE);
|
||||
unsigned int conf_target = ParseConfirmTarget(request.params[0], max_target);
|
||||
bool conservative = true;
|
||||
if (!request.params[1].isNull()) {
|
||||
@@ -1073,7 +1076,7 @@ static RPCHelpMan estimatesmartfee()
|
||||
UniValue result(UniValue::VOBJ);
|
||||
UniValue errors(UniValue::VARR);
|
||||
FeeCalculation feeCalc;
|
||||
CFeeRate feeRate = ::feeEstimator.estimateSmartFee(conf_target, &feeCalc, conservative);
|
||||
CFeeRate feeRate = fee_estimator.estimateSmartFee(conf_target, &feeCalc, conservative);
|
||||
if (feeRate != CFeeRate(0)) {
|
||||
result.pushKV("feerate", ValueFromAmount(feeRate.GetFeePerK()));
|
||||
} else {
|
||||
@@ -1144,7 +1147,10 @@ static RPCHelpMan estimaterawfee()
|
||||
{
|
||||
RPCTypeCheck(request.params, {UniValue::VNUM, UniValue::VNUM}, true);
|
||||
RPCTypeCheckArgument(request.params[0], UniValue::VNUM);
|
||||
unsigned int max_target = ::feeEstimator.HighestTargetTracked(FeeEstimateHorizon::LONG_HALFLIFE);
|
||||
|
||||
CBlockPolicyEstimator& fee_estimator = EnsureFeeEstimator(request.context);
|
||||
|
||||
unsigned int max_target = fee_estimator.HighestTargetTracked(FeeEstimateHorizon::LONG_HALFLIFE);
|
||||
unsigned int conf_target = ParseConfirmTarget(request.params[0], max_target);
|
||||
double threshold = 0.95;
|
||||
if (!request.params[1].isNull()) {
|
||||
@@ -1161,9 +1167,9 @@ static RPCHelpMan estimaterawfee()
|
||||
EstimationResult buckets;
|
||||
|
||||
// Only output results for horizons which track the target
|
||||
if (conf_target > ::feeEstimator.HighestTargetTracked(horizon)) continue;
|
||||
if (conf_target > fee_estimator.HighestTargetTracked(horizon)) continue;
|
||||
|
||||
feeRate = ::feeEstimator.estimateRawFee(conf_target, threshold, horizon, &buckets);
|
||||
feeRate = fee_estimator.estimateRawFee(conf_target, threshold, horizon, &buckets);
|
||||
UniValue horizon_result(UniValue::VOBJ);
|
||||
UniValue errors(UniValue::VARR);
|
||||
UniValue passbucket(UniValue::VOBJ);
|
||||
|
||||
Reference in New Issue
Block a user