mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-10 03:47:29 -03:00
Add multiplication operator to CFeeRate
This commit is contained in:
parent
2e8ec6b338
commit
1553c80786
2 changed files with 8 additions and 0 deletions
|
@ -71,6 +71,8 @@ public:
|
||||||
friend bool operator!=(const CFeeRate& a, const CFeeRate& b) { return a.nSatoshisPerK != b.nSatoshisPerK; }
|
friend bool operator!=(const CFeeRate& a, const CFeeRate& b) { return a.nSatoshisPerK != b.nSatoshisPerK; }
|
||||||
CFeeRate& operator+=(const CFeeRate& a) { nSatoshisPerK += a.nSatoshisPerK; return *this; }
|
CFeeRate& operator+=(const CFeeRate& a) { nSatoshisPerK += a.nSatoshisPerK; return *this; }
|
||||||
std::string ToString(const FeeEstimateMode& fee_estimate_mode = FeeEstimateMode::BTC_KVB) const;
|
std::string ToString(const FeeEstimateMode& fee_estimate_mode = FeeEstimateMode::BTC_KVB) const;
|
||||||
|
friend CFeeRate operator*(const CFeeRate& f, int a) { return CFeeRate(a * f.nSatoshisPerK); }
|
||||||
|
friend CFeeRate operator*(int a, const CFeeRate& f) { return CFeeRate(a * f.nSatoshisPerK); }
|
||||||
|
|
||||||
SERIALIZE_METHODS(CFeeRate, obj) { READWRITE(obj.nSatoshisPerK); }
|
SERIALIZE_METHODS(CFeeRate, obj) { READWRITE(obj.nSatoshisPerK); }
|
||||||
};
|
};
|
||||||
|
|
|
@ -85,6 +85,12 @@ BOOST_AUTO_TEST_CASE(GetFeeTest)
|
||||||
BOOST_CHECK(CFeeRate(CAmount(27), 789) == CFeeRate(34));
|
BOOST_CHECK(CFeeRate(CAmount(27), 789) == CFeeRate(34));
|
||||||
// Maximum size in bytes, should not crash
|
// Maximum size in bytes, should not crash
|
||||||
CFeeRate(MAX_MONEY, std::numeric_limits<uint32_t>::max()).GetFeePerK();
|
CFeeRate(MAX_MONEY, std::numeric_limits<uint32_t>::max()).GetFeePerK();
|
||||||
|
|
||||||
|
// check multiplication operator
|
||||||
|
feeRate = CFeeRate(1000);
|
||||||
|
BOOST_CHECK(0 * feeRate == CFeeRate(0));
|
||||||
|
BOOST_CHECK(3 * feeRate == CFeeRate(3000));
|
||||||
|
BOOST_CHECK(-3 * feeRate == CFeeRate(-3000));
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(BinaryOperatorTest)
|
BOOST_AUTO_TEST_CASE(BinaryOperatorTest)
|
||||||
|
|
Loading…
Reference in a new issue