From 9c85b91dc1566f7c27c5b8a1a9c7aebe0e3a83cf Mon Sep 17 00:00:00 2001 From: Alex Morcos Date: Tue, 6 Jun 2017 13:08:27 -0400 Subject: Change API to estimaterawfee Report results for all 3 possible time horizons instead of specifying time horizon as an argument. --- src/policy/feerate.h | 1 + src/policy/fees.cpp | 13 +++++++++++++ src/policy/fees.h | 2 ++ 3 files changed, 16 insertions(+) (limited to 'src/policy') diff --git a/src/policy/feerate.h b/src/policy/feerate.h index e82268b095..565da6c154 100644 --- a/src/policy/feerate.h +++ b/src/policy/feerate.h @@ -40,6 +40,7 @@ public: friend bool operator==(const CFeeRate& a, const CFeeRate& b) { return a.nSatoshisPerK == b.nSatoshisPerK; } friend bool operator<=(const CFeeRate& a, const CFeeRate& b) { return a.nSatoshisPerK <= b.nSatoshisPerK; } friend bool operator>=(const CFeeRate& a, const CFeeRate& b) { return a.nSatoshisPerK >= b.nSatoshisPerK; } + friend bool operator!=(const CFeeRate& a, const CFeeRate& b) { return a.nSatoshisPerK != b.nSatoshisPerK; } CFeeRate& operator+=(const CFeeRate& a) { nSatoshisPerK += a.nSatoshisPerK; return *this; } std::string ToString() const; diff --git a/src/policy/fees.cpp b/src/policy/fees.cpp index 771491770e..859a2e7804 100644 --- a/src/policy/fees.cpp +++ b/src/policy/fees.cpp @@ -16,6 +16,19 @@ static constexpr double INF_FEERATE = 1e99; +std::string StringForFeeEstimateHorizon(FeeEstimateHorizon horizon) { + static const std::map horizon_strings = { + {FeeEstimateHorizon::SHORT_HALFLIFE, "short"}, + {FeeEstimateHorizon::MED_HALFLIFE, "medium"}, + {FeeEstimateHorizon::LONG_HALFLIFE, "long"}, + }; + auto horizon_string = horizon_strings.find(horizon); + + if (horizon_string == horizon_strings.end()) return "unknown"; + + return horizon_string->second; +} + std::string StringForFeeReason(FeeReason reason) { static const std::map fee_reason_strings = { {FeeReason::NONE, "None"}, diff --git a/src/policy/fees.h b/src/policy/fees.h index 2029ce3744..86f143b233 100644 --- a/src/policy/fees.h +++ b/src/policy/fees.h @@ -74,6 +74,8 @@ enum FeeEstimateHorizon { LONG_HALFLIFE = 2 }; +std::string StringForFeeEstimateHorizon(FeeEstimateHorizon horizon); + /* Enumeration of reason for returned fee estimate */ enum class FeeReason { NONE, -- cgit v1.2.3