aboutsummaryrefslogtreecommitdiff
path: root/src/policy/fees.h
diff options
context:
space:
mode:
authorAlex Morcos <morcos@chaincode.com>2017-04-25 15:39:32 -0400
committerAlex Morcos <morcos@chaincode.com>2017-06-13 12:35:04 -0400
commit1bebfc8d3aa615dfdd0221f21b87319e36821b71 (patch)
tree092a7224efb48fac182bc26aa2aef39844884c01 /src/policy/fees.h
parent9c248e39f2807a7f89e555e99cc55cb2de1ad335 (diff)
downloadbitcoin-1bebfc8d3aa615dfdd0221f21b87319e36821b71.tar.xz
Output Fee Estimation Calculations in CreateTransaction
Diffstat (limited to 'src/policy/fees.h')
-rw-r--r--src/policy/fees.h34
1 files changed, 29 insertions, 5 deletions
diff --git a/src/policy/fees.h b/src/policy/fees.h
index e99fec2c39..7125a74f03 100644
--- a/src/policy/fees.h
+++ b/src/policy/fees.h
@@ -74,6 +74,22 @@ enum FeeEstimateHorizon {
LONG_HALFLIFE = 2
};
+/* Enumeration of reason for returned fee estimate */
+enum class FeeReason {
+ NONE,
+ HALF_ESTIMATE,
+ FULL_ESTIMATE,
+ DOUBLE_ESTIMATE,
+ CONSERVATIVE,
+ MEMPOOL_MIN,
+ PAYTXFEE,
+ FALLBACK,
+ REQUIRED,
+ MAXTXFEE,
+};
+
+std::string StringForFeeReason(FeeReason reason);
+
/* Used to return detailed information about a feerate bucket */
struct EstimatorBucket
{
@@ -90,8 +106,16 @@ struct EstimationResult
{
EstimatorBucket pass;
EstimatorBucket fail;
- double decay;
- unsigned int scale;
+ double decay = 0;
+ unsigned int scale = 0;
+};
+
+struct FeeCalculation
+{
+ EstimationResult est;
+ FeeReason reason = FeeReason::NONE;
+ int desiredTarget = 0;
+ int returnedTarget = 0;
};
/**
@@ -173,7 +197,7 @@ public:
* the closest target where one can be given. 'conservative' estimates are
* valid over longer time horizons also.
*/
- CFeeRate estimateSmartFee(int confTarget, int *answerFoundAtTarget, const CTxMemPool& pool, bool conservative = true) const;
+ CFeeRate estimateSmartFee(int confTarget, FeeCalculation *feeCalc, const CTxMemPool& pool, bool conservative = true) const;
/** Return a specific fee estimate calculation with a given success
* threshold and time horizon, and optionally return detailed data about
@@ -223,9 +247,9 @@ private:
bool processBlockTx(unsigned int nBlockHeight, const CTxMemPoolEntry* entry);
/** Helper for estimateSmartFee */
- double estimateCombinedFee(unsigned int confTarget, double successThreshold, bool checkShorterHorizon) const;
+ double estimateCombinedFee(unsigned int confTarget, double successThreshold, bool checkShorterHorizon, EstimationResult *result) const;
/** Helper for estimateSmartFee */
- double estimateConservativeFee(unsigned int doubleTarget) const;
+ double estimateConservativeFee(unsigned int doubleTarget, EstimationResult *result) const;
/** Number of blocks of data recorded while fee estimates have been running */
unsigned int BlockSpan() const;
/** Number of blocks of recorded fee estimate data represented in saved data file */