Skip to content

Commit

Permalink
[FOLD] Last minute tweaks:
Browse files Browse the repository at this point in the history
* Range check in fee vote
* Simplify `divide` in fee track
* Fix comment
* Remove extra indent
  • Loading branch information
ximinez committed Oct 21, 2019
1 parent 31281cb commit 2cc5476
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/ripple/app/misc/FeeVoteImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ FeeVoteImpl::doVoting(
if (val->isFieldPresent (sfBaseFee))
{
auto const vote = val->getFieldU64 (sfBaseFee);
if (isLegalAmount(vote))
if (vote <= std::numeric_limits<XRPAmount::value_type>::max())
baseFeeVote.addVote(XRPAmount{
unsafe_cast<XRPAmount::value_type>(vote)});
else
Expand Down
10 changes: 3 additions & 7 deletions src/ripple/app/misc/impl/LoadFeeTrack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,21 +96,17 @@ scaleFeeLoad(FeeUnit64 fee, LoadFeeTrack const& feeTrack,
// compatible. This function is an exception.
auto lowestTerms = [](auto& a, auto& b)
{
auto value = [](auto val)
auto const value = [](auto val)
{
if constexpr(std::is_arithmetic_v<decltype(val)>)
return val;
else
return val.value();
};

auto divide = [](auto& val, auto gcd)
auto const divide = [&value](auto& val, auto gcd)
{
if constexpr(std::is_arithmetic_v<std::remove_reference_t<
decltype(val)>>)
return val /= gcd;
else
return val = val.value() / gcd;
val = value(val) / gcd;
};

if (auto const g = std::gcd(value(a), value(b)))
Expand Down
2 changes: 1 addition & 1 deletion src/ripple/basics/XRPAmount.h
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ class XRPAmount
if ((drops_ > std::numeric_limits<Dest>::max()) ||
(!std::numeric_limits<Dest>::is_signed && drops_ < 0) ||
(std::numeric_limits<Dest>::is_signed &&
drops_ < std::numeric_limits<Dest>::lowest()))
drops_ < std::numeric_limits<Dest>::lowest()))
{
return boost::none;
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/basics/XRPAmount_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ class XRPAmount_test : public beast::unit_test::suite

void testFunctions()
{
// Explicitly test every defined function for the TaggedFee class
// Explicitly test every defined function for the XRPAmount class
// since some of them are templated, but not used anywhere else.
auto make = [&](auto x) -> XRPAmount {
return x; };
Expand Down

0 comments on commit 2cc5476

Please sign in to comment.