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
+2 -2
View File
@@ -714,7 +714,7 @@ CFeeRate CBlockPolicyEstimator::estimateRawFee(int confTarget, double successThr
if (median < 0)
return CFeeRate(0);
return CFeeRate(median);
return CFeeRate(llround(median));
}
unsigned int CBlockPolicyEstimator::HighestTargetTracked(FeeEstimateHorizon horizon) const
@@ -901,7 +901,7 @@ CFeeRate CBlockPolicyEstimator::estimateSmartFee(int confTarget, FeeCalculation
if (median < 0) return CFeeRate(0); // error condition
return CFeeRate(median);
return CFeeRate(llround(median));
}