LCOV - code coverage report
Current view: top level - src/policy - feerate.h (source / functions) Hit Total Coverage
Test: coverage.lcov Lines: 12 12 100.0 %
Date: 2022-04-21 14:51:19 Functions: 14 14 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: 0 0 -

           Branch data     Line data    Source code
#       1                 :            : // Copyright (c) 2009-2010 Satoshi Nakamoto
#       2                 :            : // Copyright (c) 2009-2021 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                 :            : #ifndef BITCOIN_POLICY_FEERATE_H
#       7                 :            : #define BITCOIN_POLICY_FEERATE_H
#       8                 :            : 
#       9                 :            : #include <consensus/amount.h>
#      10                 :            : #include <serialize.h>
#      11                 :            : 
#      12                 :            : #include <string>
#      13                 :            : 
#      14                 :            : const std::string CURRENCY_UNIT = "BTC"; // One formatted unit
#      15                 :            : const std::string CURRENCY_ATOM = "sat"; // One indivisible minimum value unit
#      16                 :            : 
#      17                 :            : /* Used to determine type of fee estimation requested */
#      18                 :            : enum class FeeEstimateMode {
#      19                 :            :     UNSET,        //!< Use default settings based on other criteria
#      20                 :            :     ECONOMICAL,   //!< Force estimateSmartFee to use non-conservative estimates
#      21                 :            :     CONSERVATIVE, //!< Force estimateSmartFee to use conservative estimates
#      22                 :            :     BTC_KVB,      //!< Use BTC/kvB fee rate unit
#      23                 :            :     SAT_VB,       //!< Use sat/vB fee rate unit
#      24                 :            : };
#      25                 :            : 
#      26                 :            : /**
#      27                 :            :  * Fee rate in satoshis per kilovirtualbyte: CAmount / kvB
#      28                 :            :  */
#      29                 :            : class CFeeRate
#      30                 :            : {
#      31                 :            : private:
#      32                 :            :     /** Fee rate in sat/kvB (satoshis per 1000 virtualbytes) */
#      33                 :            :     CAmount nSatoshisPerK;
#      34                 :            : 
#      35                 :            : public:
#      36                 :            :     /** Fee rate of 0 satoshis per kvB */
#      37                 :      78928 :     CFeeRate() : nSatoshisPerK(0) { }
#      38                 :            :     template<typename I>
#      39                 :    1169493 :     explicit CFeeRate(const I _nSatoshisPerK): nSatoshisPerK(_nSatoshisPerK) {
#      40                 :            :         // We've previously had bugs creep in from silent double->int conversion...
#      41                 :    1169493 :         static_assert(std::is_integral<I>::value, "CFeeRate should be used without floats");
#      42                 :    1169493 :     }
#      43                 :            : 
#      44                 :            :     /**
#      45                 :            :      * Construct a fee rate from a fee in satoshis and a vsize in vB.
#      46                 :            :      *
#      47                 :            :      * param@[in]   nFeePaid    The fee paid by a transaction, in satoshis
#      48                 :            :      * param@[in]   num_bytes   The vsize of a transaction, in vbytes
#      49                 :            :      */
#      50                 :            :     CFeeRate(const CAmount& nFeePaid, uint32_t num_bytes);
#      51                 :            : 
#      52                 :            :     /**
#      53                 :            :      * Return the fee in satoshis for the given vsize in vbytes.
#      54                 :            :      * If the calculated fee would have fractional satoshis, then the
#      55                 :            :      * returned fee will always be rounded up to the nearest satoshi.
#      56                 :            :      */
#      57                 :            :     CAmount GetFee(uint32_t num_bytes) const;
#      58                 :            : 
#      59                 :            :     /**
#      60                 :            :      * Return the fee in satoshis for a vsize of 1000 vbytes
#      61                 :            :      */
#      62                 :     737643 :     CAmount GetFeePerK() const { return GetFee(1000); }
#      63                 :      19416 :     friend bool operator<(const CFeeRate& a, const CFeeRate& b) { return a.nSatoshisPerK < b.nSatoshisPerK; }
#      64                 :      28543 :     friend bool operator>(const CFeeRate& a, const CFeeRate& b) { return a.nSatoshisPerK > b.nSatoshisPerK; }
#      65                 :      12051 :     friend bool operator==(const CFeeRate& a, const CFeeRate& b) { return a.nSatoshisPerK == b.nSatoshisPerK; }
#      66                 :       1865 :     friend bool operator<=(const CFeeRate& a, const CFeeRate& b) { return a.nSatoshisPerK <= b.nSatoshisPerK; }
#      67                 :          4 :     friend bool operator>=(const CFeeRate& a, const CFeeRate& b) { return a.nSatoshisPerK >= b.nSatoshisPerK; }
#      68                 :       5344 :     friend bool operator!=(const CFeeRate& a, const CFeeRate& b) { return a.nSatoshisPerK != b.nSatoshisPerK; }
#      69                 :        295 :     CFeeRate& operator+=(const CFeeRate& a) { nSatoshisPerK += a.nSatoshisPerK; return *this; }
#      70                 :            :     std::string ToString(const FeeEstimateMode& fee_estimate_mode = FeeEstimateMode::BTC_KVB) const;
#      71                 :            : 
#      72                 :            :     SERIALIZE_METHODS(CFeeRate, obj) { READWRITE(obj.nSatoshisPerK); }
#      73                 :            : };
#      74                 :            : 
#      75                 :            : #endif // BITCOIN_POLICY_FEERATE_H

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