Skip to content

Commit

Permalink
[FOLD] Minor refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
gregtatcam committed Oct 26, 2023
1 parent 1565b0e commit fc7c0e7
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/ripple/app/tx/impl/SetOracle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ SetOracle::preclaim(PreclaimContext const& ctx)
if (!entry.isFieldPresent(sfSymbolPrice))
return temMALFORMED;
auto const hash = tokenPairHash(entry);
if (pairs.contains(tokenPairHash(entry)))
if (pairs.contains(hash))
return tecDUPLICATE;
pairs.emplace(hash);
}
Expand Down Expand Up @@ -114,15 +114,13 @@ SetOracle::preclaim(PreclaimContext const& ctx)
if (pairs.size() > maxOracleDataSeries)
return temARRAY_SIZE;

auto const add = pairs.size() <= 5 ? 1 : 2;
auto const reserve = ctx.view.fees().accountReserve(
sleSetter->getFieldU32(sfOwnerCount) + pairs.size() <= 5 ? 1 : 2);
sleSetter->getFieldU32(sfOwnerCount) + add);
auto const& balance = sleSetter->getFieldAmount(sfBalance);

if (balance < reserve)
{
JLOG(ctx.j.debug()) << "Oracle Set: insufficient reserve";
return tecINSUFFICIENT_RESERVE;
}

return tesSUCCESS;
}
Expand Down Expand Up @@ -181,7 +179,7 @@ applySet(
}
}
STArray updatedSeries;
for (auto iter : pairs)
for (auto const& iter : pairs)
updatedSeries.push_back(std::move(iter.second));
sle->setFieldArray(sfPriceDataSeries, updatedSeries);
if (ctx_.tx.isFieldPresent(sfURI))
Expand Down

0 comments on commit fc7c0e7

Please sign in to comment.