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

          Line data    Source code
       1             : // Copyright (c) 2009-2010 Satoshi Nakamoto
       2             : // Copyright (c) 2009-2017 The Bitcoin developers
       3             : // Copyright (c) 2017-2020 The PIVX Core developers
       4             : // Distributed under the MIT software license, see the accompanying
       5             : // file COPYING or http://www.opensource.org/licenses/mit-license.php.
       6             : 
       7             : #include "feerate.h"
       8             : 
       9             : #include "tinyformat.h"
      10             : 
      11             : const std::string CURRENCY_UNIT = "PIV";
      12             : 
      13      280785 : CFeeRate::CFeeRate(const CAmount& nFeePaid, size_t nSize)
      14             : {
      15      280785 :     if (nSize > 0)
      16      280785 :         nSatoshisPerK = nFeePaid * 1000 / nSize;
      17             :     else
      18           0 :         nSatoshisPerK = 0;
      19      280785 : }
      20             : 
      21     1387661 : CAmount CFeeRate::GetFee(size_t nSize) const
      22             : {
      23     1387661 :     CAmount nFee = nSatoshisPerK * nSize / 1000;
      24             : 
      25     1387661 :     if (nFee == 0 && nSatoshisPerK > 0)
      26           0 :         nFee = nSatoshisPerK;
      27             : 
      28     1387661 :     return nFee;
      29             : }
      30             : 
      31           2 : std::string CFeeRate::ToString() const
      32             : {
      33           2 :     return strprintf("%d.%08d %s/kB", nSatoshisPerK / COIN, nSatoshisPerK % COIN, CURRENCY_UNIT);
      34             : }

Generated by: LCOV version 1.14