LCOV - code coverage report
Current view: top level - src/policy - feerate.h (source / functions) Hit Total Coverage
Test: total_coverage.info Lines: 7 7 100.0 %
Date: 2025-02-23 09:33:43 Functions: 0 0 -

          Line data    Source code
       1             : // Copyright (c) 2009-2017 The Bitcoin Core developers
       2             : // Copyright (c) 2017-2020 The PIVX 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 PIVX_POLICY_FEERATE_H
       7             : #define PIVX_POLICY_FEERATE_H
       8             : 
       9             : #include "amount.h"
      10             : #include "serialize.h"
      11             : 
      12             : #include <string>
      13             : 
      14             : extern const std::string CURRENCY_UNIT;
      15             : 
      16             : /**
      17             :  * Fee rate in PIV per kilobyte: CAmount / kB
      18             :  */
      19             : class CFeeRate
      20             : {
      21             : private:
      22             :     CAmount nSatoshisPerK; // unit is satoshis-per-1,000-bytes
      23             : public:
      24      196304 :     CFeeRate() : nSatoshisPerK(0) {}
      25      293683 :     explicit CFeeRate(const CAmount& _nSatoshisPerK) : nSatoshisPerK(_nSatoshisPerK) {}
      26             :     CFeeRate(const CAmount& nFeePaid, size_t nSize);
      27             : 
      28             :     CAmount GetFee(size_t size) const;                  // unit returned is satoshis
      29      262189 :     CAmount GetFeePerK() const { return GetFee(1000); } // satoshis-per-1000-bytes
      30             : 
      31         874 :     friend bool operator<(const CFeeRate& a, const CFeeRate& b) { return a.nSatoshisPerK < b.nSatoshisPerK; }
      32      290637 :     friend bool operator>(const CFeeRate& a, const CFeeRate& b) { return a.nSatoshisPerK > b.nSatoshisPerK; }
      33         203 :     friend bool operator==(const CFeeRate& a, const CFeeRate& b) { return a.nSatoshisPerK == b.nSatoshisPerK; }
      34             :     friend bool operator<=(const CFeeRate& a, const CFeeRate& b) { return a.nSatoshisPerK <= b.nSatoshisPerK; }
      35             :     friend bool operator>=(const CFeeRate& a, const CFeeRate& b) { return a.nSatoshisPerK >= b.nSatoshisPerK; }
      36           8 :     CFeeRate& operator+=(const CFeeRate& a) { nSatoshisPerK += a.nSatoshisPerK; return *this; }
      37             :     std::string ToString() const;
      38             : 
      39             :     SERIALIZE_METHODS(CFeeRate, obj) { READWRITE(obj.nSatoshisPerK); }
      40             : };
      41             : 
      42             : #endif // PIVX_POLICY_FEERATE_H

Generated by: LCOV version 1.14