Skip to content

Commit 4e6f210

Browse files
committed
[FOLD] Address @seelabs feedback
* Remove comments * Refactor amendment changed code
1 parent 87a2879 commit 4e6f210

File tree

4 files changed

+26
-17
lines changed

4 files changed

+26
-17
lines changed

src/ripple/app/misc/impl/AMMUtils.cpp

+16-7
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,6 @@ std::uint16_t
138138
getTradingFee(ReadView const& view, SLE const& ammSle, AccountID const& account)
139139
{
140140
using namespace std::chrono;
141-
// should not happen
142141
assert(
143142
!view.rules().enabled(fixInnerObjTemplate) ||
144143
ammSle.isFieldPresent(sfAuctionSlot));
@@ -304,12 +303,22 @@ initializeFeeAuctionVote(
304303
// AMM creator gets the auction slot for free.
305304
// AuctionSlot is created on AMMCreate and updated on AMMDeposit
306305
// when AMM is in an empty state
307-
if (!ammSle->isFieldPresent(sfAuctionSlot))
308-
{
309-
STObject auctionSlot = STObject::makeInnerObject(sfAuctionSlot, rules);
310-
ammSle->set(&auctionSlot);
311-
}
312-
STObject& auctionSlot = ammSle->peekFieldObject(sfAuctionSlot);
306+
STObject& auctionSlot = [&]() -> STObject& {
307+
if (!rules.enabled(fixInnerObjTemplate))
308+
{
309+
return ammSle->peekFieldObject(sfAuctionSlot);
310+
}
311+
else
312+
{
313+
if (!ammSle->isFieldPresent(sfAuctionSlot))
314+
{
315+
STObject auctionSlot =
316+
STObject::makeInnerObject(sfAuctionSlot, rules);
317+
ammSle->set(&auctionSlot);
318+
}
319+
return ammSle->peekFieldObject(sfAuctionSlot);
320+
}
321+
}();
313322
auctionSlot.setAccountID(sfAccount, account);
314323
// current + sec in 24h
315324
auto const expiration = std::chrono::duration_cast<std::chrono::seconds>(

src/ripple/app/tx/impl/AMMBid.cpp

+10-8
Original file line numberDiff line numberDiff line change
@@ -173,15 +173,17 @@ applyBid(
173173
return {tecINTERNAL, false};
174174
STAmount const lptAMMBalance = (*ammSle)[sfLPTokenBalance];
175175
auto const lpTokens = ammLPHolds(sb, *ammSle, account_, ctx_.journal);
176-
// should not happen
177-
assert(
178-
!ctx_.view().rules().enabled(fixInnerObjTemplate) ||
179-
ammSle->isFieldPresent(sfAuctionSlot));
180-
if (!ammSle->isFieldPresent(sfAuctionSlot))
176+
auto const& rules = ctx_.view().rules();
177+
if (!rules.enabled(fixInnerObjTemplate))
181178
{
182-
STObject auctionSlot =
183-
STObject::makeInnerObject(sfAuctionSlot, ctx_.view().rules());
184-
ammSle->set(&auctionSlot);
179+
if (!ammSle->isFieldPresent(sfAuctionSlot))
180+
ammSle->makeFieldPresent(sfAuctionSlot);
181+
}
182+
else
183+
{
184+
assert(ammSle->isFieldPresent(sfAuctionSlot));
185+
if (!ammSle->isFieldPresent(sfAuctionSlot))
186+
return {tecINTERNAL, false};
185187
}
186188
auto& auctionSlot = ammSle->peekFieldObject(sfAuctionSlot);
187189
auto const current =

src/ripple/app/tx/impl/AMMVote.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,6 @@ applyVote(
200200
}
201201
}
202202

203-
// should not happen
204203
assert(
205204
!ctx_.view().rules().enabled(fixInnerObjTemplate) ||
206205
ammSle->isFieldPresent(sfAuctionSlot));

src/ripple/rpc/handlers/AMMInfo.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,6 @@ doAMMInfo(RPC::JsonContext& context)
200200
}
201201
if (voteSlots.size() > 0)
202202
ammResult[jss::vote_slots] = std::move(voteSlots);
203-
// should not happen
204203
assert(
205204
!ledger->rules().enabled(fixInnerObjTemplate) ||
206205
amm->isFieldPresent(sfAuctionSlot));

0 commit comments

Comments
 (0)