Skip to content

Commit

Permalink
[FOLD] Review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
ximinez committed Oct 22, 2019
1 parent 2cc5476 commit abbf1eb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
4 changes: 3 additions & 1 deletion src/ripple/app/misc/FeeVoteImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,10 @@ FeeVoteImpl::doVoting(
{
if (val->isFieldPresent (sfBaseFee))
{
using xrptype = XRPAmount::value_type;
auto const vote = val->getFieldU64 (sfBaseFee);
if (vote <= std::numeric_limits<XRPAmount::value_type>::max())
if (vote <= std::numeric_limits<xrptype>::max() &&
isLegalAmount(XRPAmount{unsafe_cast<xrptype>(vote)}))
baseFeeVote.addVote(XRPAmount{
unsafe_cast<XRPAmount::value_type>(vote)});
else
Expand Down
11 changes: 3 additions & 8 deletions src/ripple/app/misc/impl/LoadFeeTrack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,23 +96,18 @@ scaleFeeLoad(FeeUnit64 fee, LoadFeeTrack const& feeTrack,
// compatible. This function is an exception.
auto lowestTerms = [](auto& a, auto& b)
{
auto const value = [](auto val)
auto value = [](auto val)
{
if constexpr(std::is_arithmetic_v<decltype(val)>)
return val;
else
return val.value();
};

auto const divide = [&value](auto& val, auto gcd)
{
val = value(val) / gcd;
};

if (auto const g = std::gcd(value(a), value(b)))
{
divide(a, g);
divide(b, g);
a = value(a) / g;
b = value(b) / g;
}
};

Expand Down

0 comments on commit abbf1eb

Please sign in to comment.