4 #include <utils/serialize.h> 7 typedef int64_t CAmount;
10 static int64_t COIN = 100000000;
12 static int64_t MAX_MONEY = 21000000 * COIN;
14 inline bool MoneyRange(
const CAmount& nValue) {
return (nValue >= 0 && nValue <= MAX_MONEY); }
22 CAmount nSatoshisPerK;
25 explicit CFeeRate(
const CAmount& _nSatoshisPerK): nSatoshisPerK(_nSatoshisPerK) { }
26 CFeeRate(
const CAmount& nFeePaid,
size_t nSize);
29 CAmount GetFee(
size_t size)
const;
30 CAmount GetFeePerK()
const {
return GetFee(1000); }
32 friend bool operator<(
const CFeeRate& a,
const CFeeRate& b) {
return a.nSatoshisPerK < b.nSatoshisPerK; }
33 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 friend bool operator>=(
const CFeeRate& a,
const CFeeRate& b) {
return a.nSatoshisPerK >= b.nSatoshisPerK; }
37 std::string ToString()
const;
39 ADD_SERIALIZE_METHODS;
41 template <
typename Stream,
typename Operation>
42 inline void SerializationOp(Stream& s, Operation ser_action,
int nType,
int nVersion) {
43 READWRITE(nSatoshisPerK);