mirror of
https://github.com/XRPLF/rippled.git
synced 2026-07-27 17:10:46 +00:00
refactor: change the return type of mulDiv to std::optional (#4243)
- Previously, mulDiv had `std::pair<bool, uint64_t>` as the output type.
- This is an error-prone interface as it is easy to ignore when
overflow occurs.
- Using a return type of `std::optional` should decrease the likelihood
of ignoring overflow.
- It also allows for the use of optional::value_or() as a way to
explicitly recover from overflow.
- Include limits.h header file preprocessing directive in order to
satisfy gcc's numeric_limits incomplete_type requirement.
Fix #3495
---------
Co-authored-by: John Freeman <jfreeman08@gmail.com>
This commit is contained in:
committed by
GitHub
parent
77dc63b549
commit
c6fee28b92
@@ -2058,7 +2058,7 @@ NetworkOPsImp::pubServer()
|
||||
f.em->openLedgerFeeLevel,
|
||||
f.loadBaseServer,
|
||||
f.em->referenceFeeLevel)
|
||||
.second);
|
||||
.value_or(ripple::muldiv_max));
|
||||
|
||||
jvObj[jss::load_factor] = trunc32(loadFactor);
|
||||
jvObj[jss::load_factor_fee_escalation] =
|
||||
@@ -2506,7 +2506,7 @@ NetworkOPsImp::getServerInfo(bool human, bool admin, bool counters)
|
||||
escalationMetrics.openLedgerFeeLevel,
|
||||
loadBaseServer,
|
||||
escalationMetrics.referenceFeeLevel)
|
||||
.second;
|
||||
.value_or(ripple::muldiv_max);
|
||||
|
||||
auto const loadFactor = std::max(
|
||||
safe_cast<std::uint64_t>(loadFactorServer),
|
||||
|
||||
Reference in New Issue
Block a user