Force explicit double -> int conversion for CFeeRate constructor

This resolves an issue where estimatesmartfee would return 999
sat/byte instead of 1000, due to floating point loss of precision

Thanks to sipa for suggesting is_integral.
This commit is contained in:
Matt Corallo
2017-09-11 15:47:09 -04:00
parent 53a6590f49
commit 1789e4675b
4 changed files with 13 additions and 8 deletions

View File

@@ -981,7 +981,7 @@ const CTxMemPool::setEntries & CTxMemPool::GetMemPoolChildren(txiter entry) cons
CFeeRate CTxMemPool::GetMinFee(size_t sizelimit) const {
LOCK(cs);
if (!blockSinceLastRollingFeeBump || rollingMinimumFeeRate == 0)
return CFeeRate(rollingMinimumFeeRate);
return CFeeRate(llround(rollingMinimumFeeRate));
int64_t time = GetTime();
if (time > lastRollingFeeUpdate + 10) {
@@ -999,7 +999,7 @@ CFeeRate CTxMemPool::GetMinFee(size_t sizelimit) const {
return CFeeRate(0);
}
}
return std::max(CFeeRate(rollingMinimumFeeRate), incrementalRelayFee);
return std::max(CFeeRate(llround(rollingMinimumFeeRate)), incrementalRelayFee);
}
void CTxMemPool::trackPackageRemoved(const CFeeRate& rate) {