Type-safe CFeeRate class
Use CFeeRate instead of an int64_t for quantities that are fee-per-size. Helps prevent unit-conversion mismatches between the wallet, relaying, and mining code.
This commit is contained in:
19
src/core.cpp
19
src/core.cpp
@@ -72,6 +72,25 @@ void CTxOut::print() const
|
||||
LogPrintf("%s\n", ToString());
|
||||
}
|
||||
|
||||
CFeeRate::CFeeRate(int64_t nFeePaid, size_t nSize)
|
||||
{
|
||||
if (nSize > 0)
|
||||
nSatoshisPerK = nFeePaid*1000/nSize;
|
||||
else
|
||||
nSatoshisPerK = 0;
|
||||
}
|
||||
|
||||
int64_t CFeeRate::GetFee(size_t nSize)
|
||||
{
|
||||
return nSatoshisPerK*nSize / 1000;
|
||||
}
|
||||
|
||||
std::string CFeeRate::ToString() const
|
||||
{
|
||||
std::string result = FormatMoney(nSatoshisPerK) + " BTC/kB";
|
||||
return result;
|
||||
}
|
||||
|
||||
uint256 CTransaction::GetHash() const
|
||||
{
|
||||
return SerializeHash(*this);
|
||||
|
||||
Reference in New Issue
Block a user