Bitcoin Core 31.99.0
P2P Digital Currency
fees.cpp
Go to the documentation of this file.
1// Copyright (c) The Bitcoin Core developers
2// Distributed under the MIT software license, see the accompanying
3// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
5#include <util/fees.h>
6
7#include <util/strencodings.h>
8
9#include <cassert>
10#include <string_view>
11
12std::string_view FeeRateEstimatorTypeToString(FeeRateEstimatorType feerate_estimator_type)
13{
14 switch (feerate_estimator_type) {
16 return "none";
18 return "block_policy";
20 return "mempool_policy";
21 }
22 // no default case, so the compiler can warn about missing cases
23 assert(false);
24}
25
26FeeRateEstimatorType FeeRateEstimatorTypeFromString(std::string_view feerate_estimator_type)
27{
28 const auto normalized{ToLower(feerate_estimator_type)};
29 if (normalized == "block_policy") return FeeRateEstimatorType::BLOCK_POLICY;
30 if (normalized == "mempool_policy") return FeeRateEstimatorType::MEMPOOL_POLICY;
32}
std::string_view FeeRateEstimatorTypeToString(FeeRateEstimatorType feerate_estimator_type)
Definition: fees.cpp:12
FeeRateEstimatorType FeeRateEstimatorTypeFromString(std::string_view feerate_estimator_type)
Definition: fees.cpp:26
FeeRateEstimatorType
Identifier for fee rate estimator.
Definition: fees.h:36
std::string ToLower(std::string_view str)
Returns the lowercase equivalent of the given string.
assert(!tx.IsCoinBase())