Skip to content

Commit

Permalink
Prefer using a local Sandbox over using the Context's view
Browse files Browse the repository at this point in the history
  • Loading branch information
scottschurr authored and nbougalis committed Mar 1, 2022
1 parent 0c13676 commit df02eb1
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/ripple/app/tx/impl/CreateOffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ CreateOffer::takerCross(
Sandbox& sbCancel,
Amounts const& takerAmount)
{
NetClock::time_point const when = ctx_.view().parentCloseTime();
NetClock::time_point const when = sb.parentCloseTime();

beast::WrappedSink takerSink(j_, "Taker ");

Expand Down Expand Up @@ -957,21 +957,20 @@ CreateOffer::applyGuts(Sandbox& sb, Sandbox& sbCancel)
// Expiration is defined in terms of the close time of the parent ledger,
// because we definitively know the time that it closed but we do not
// know the closing time of the ledger that is under construction.
if (expiration && (ctx_.view().parentCloseTime() >= tp{d{*expiration}}))
if (expiration && (sb.parentCloseTime() >= tp{d{*expiration}}))
{
// If the offer has expired, the transaction has successfully
// done nothing, so short circuit from here.
//
// The return code change is attached to featureDepositPreauth as a
// convenience. The change is not big enough to deserve a fix code.
TER const ter{
ctx_.view().rules().enabled(featureDepositPreauth)
? TER{tecEXPIRED}
: TER{tesSUCCESS}};
sb.rules().enabled(featureDepositPreauth) ? TER{tecEXPIRED}
: TER{tesSUCCESS}};
return {ter, true};
}

bool const bOpenLedger = ctx_.view().open();
bool const bOpenLedger = sb.open();
bool crossed = false;

if (result == tesSUCCESS)
Expand Down Expand Up @@ -1129,8 +1128,8 @@ CreateOffer::applyGuts(Sandbox& sb, Sandbox& sbCancel)
return {tefINTERNAL, false};

{
XRPAmount reserve = ctx_.view().fees().accountReserve(
sleCreator->getFieldU32(sfOwnerCount) + 1);
XRPAmount reserve =
sb.fees().accountReserve(sleCreator->getFieldU32(sfOwnerCount) + 1);

if (mPriorBalance < reserve)
{
Expand Down

0 comments on commit df02eb1

Please sign in to comment.