LCOV - code coverage report
Current view: top level - src/util - fees.cpp (source / functions) Hit Total Coverage
Test: coverage.lcov Lines: 40 40 100.0 %
Date: 2022-04-21 14:51:19 Functions: 6 6 100.0 %
Legend: Modified by patch:
Lines: hit not hit | Branches: + taken - not taken # not executed

Not modified by patch:
Lines: hit not hit | Branches: + taken - not taken # not executed
Branches: 5 6 83.3 %

           Branch data     Line data    Source code
#       1                 :            : // Copyright (c) 2009-2010 Satoshi Nakamoto
#       2                 :            : // Copyright (c) 2009-2020 The Bitcoin Core developers
#       3                 :            : // Distributed under the MIT software license, see the accompanying
#       4                 :            : // file COPYING or http://www.opensource.org/licenses/mit-license.php.
#       5                 :            : 
#       6                 :            : #include <util/fees.h>
#       7                 :            : 
#       8                 :            : #include <policy/fees.h>
#       9                 :            : #include <util/strencodings.h>
#      10                 :            : #include <util/string.h>
#      11                 :            : 
#      12                 :            : #include <map>
#      13                 :            : #include <string>
#      14                 :            : #include <vector>
#      15                 :            : #include <utility>
#      16                 :            : 
#      17                 :            : std::string StringForFeeReason(FeeReason reason)
#      18                 :       5309 : {
#      19                 :       5309 :     static const std::map<FeeReason, std::string> fee_reason_strings = {
#      20                 :       5309 :         {FeeReason::NONE, "None"},
#      21                 :       5309 :         {FeeReason::HALF_ESTIMATE, "Half Target 60% Threshold"},
#      22                 :       5309 :         {FeeReason::FULL_ESTIMATE, "Target 85% Threshold"},
#      23                 :       5309 :         {FeeReason::DOUBLE_ESTIMATE, "Double Target 95% Threshold"},
#      24                 :       5309 :         {FeeReason::CONSERVATIVE, "Conservative Double Target longer horizon"},
#      25                 :       5309 :         {FeeReason::MEMPOOL_MIN, "Mempool Min Fee"},
#      26                 :       5309 :         {FeeReason::PAYTXFEE, "PayTxFee set"},
#      27                 :       5309 :         {FeeReason::FALLBACK, "Fallback fee"},
#      28                 :       5309 :         {FeeReason::REQUIRED, "Minimum Required Fee"},
#      29                 :       5309 :     };
#      30                 :       5309 :     auto reason_string = fee_reason_strings.find(reason);
#      31                 :            : 
#      32         [ -  + ]:       5309 :     if (reason_string == fee_reason_strings.end()) return "Unknown";
#      33                 :            : 
#      34                 :       5309 :     return reason_string->second;
#      35                 :       5309 : }
#      36                 :            : 
#      37                 :            : const std::vector<std::pair<std::string, FeeEstimateMode>>& FeeModeMap()
#      38                 :      21515 : {
#      39                 :      21515 :     static const std::vector<std::pair<std::string, FeeEstimateMode>> FEE_MODES = {
#      40                 :      21515 :         {"unset", FeeEstimateMode::UNSET},
#      41                 :      21515 :         {"economical", FeeEstimateMode::ECONOMICAL},
#      42                 :      21515 :         {"conservative", FeeEstimateMode::CONSERVATIVE},
#      43                 :      21515 :     };
#      44                 :      21515 :     return FEE_MODES;
#      45                 :      21515 : }
#      46                 :            : 
#      47                 :            : std::string FeeModes(const std::string& delimiter)
#      48                 :      21383 : {
#      49                 :      64149 :     return Join(FeeModeMap(), delimiter, [&](const std::pair<std::string, FeeEstimateMode>& i) { return i.first; });
#      50                 :      21383 : }
#      51                 :            : 
#      52                 :            : const std::string InvalidEstimateModeErrorMessage()
#      53                 :         59 : {
#      54                 :         59 :     return "Invalid estimate_mode parameter, must be one of: \"" + FeeModes("\", \"") + "\"";
#      55                 :         59 : }
#      56                 :            : 
#      57                 :            : bool FeeModeFromString(const std::string& mode_string, FeeEstimateMode& fee_estimate_mode)
#      58                 :        132 : {
#      59                 :        132 :     auto searchkey = ToUpper(mode_string);
#      60         [ +  + ]:        338 :     for (const auto& pair : FeeModeMap()) {
#      61         [ +  + ]:        338 :         if (ToUpper(pair.first) == searchkey) {
#      62                 :         73 :             fee_estimate_mode = pair.second;
#      63                 :         73 :             return true;
#      64                 :         73 :         }
#      65                 :        338 :     }
#      66                 :         59 :     return false;
#      67                 :        132 : }

Generated by: LCOV version 0-eol-96201-ge66f56f4af6a