diff options
author | Pieter Wuille <pieter.wuille@gmail.com> | 2014-10-28 05:22:34 -0700 |
---|---|---|
committer | Pieter Wuille <pieter.wuille@gmail.com> | 2014-10-28 05:27:41 -0700 |
commit | 723c7526368badda15df8ac1ffc047a0ab2e384a (patch) | |
tree | ee490e57014cea5b59355a48251b5df69020a90c /src/amount.cpp | |
parent | cd9114e5136ecc1f60baa43fffeeb632782f2353 (diff) | |
parent | 99f41b9cf7b8e039cea75500a905498a1f6969f3 (diff) |
Merge pull request #5100
99f41b9 MOVEONLY: core.o -> core/block.o (jtimon)
561e9e9 MOVEONLY: Move script/compressor out of script and put CTxOutCompressor (from core) with it (jtimon)
999a2ab MOVEONLY: separate CTxUndo out of core (jtimon)
4a3587d MOVEONLY: Separate CTransaction and dependencies from core (jtimon)
eda3733 MOVEONLY: Move CFeeRate and Amount constants to amount.o (jtimon)
Diffstat (limited to 'src/amount.cpp')
-rw-r--r-- | src/amount.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/amount.cpp b/src/amount.cpp new file mode 100644 index 0000000000..e6f5b7d440 --- /dev/null +++ b/src/amount.cpp @@ -0,0 +1,31 @@ +// Copyright (c) 2009-2010 Satoshi Nakamoto +// Copyright (c) 2009-2014 The Bitcoin developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include "amount.h" + +#include "tinyformat.h" + +CFeeRate::CFeeRate(const CAmount& nFeePaid, size_t nSize) +{ + if (nSize > 0) + nSatoshisPerK = nFeePaid*1000/nSize; + else + nSatoshisPerK = 0; +} + +CAmount CFeeRate::GetFee(size_t nSize) const +{ + CAmount nFee = nSatoshisPerK*nSize / 1000; + + if (nFee == 0 && nSatoshisPerK > 0) + nFee = nSatoshisPerK; + + return nFee; +} + +std::string CFeeRate::ToString() const +{ + return strprintf("%d.%08d BTC/kB", nSatoshisPerK / COIN, nSatoshisPerK % COIN); +} |