Prefer using a local Sandbox over using the Context's view

This commit is contained in:
Scott Schurr
2021-10-21 14:31:58 -07:00
committed by Nik Bougalis
parent 0c13676d5f
commit df02eb125f

View File

@@ -637,7 +637,7 @@ CreateOffer::takerCross(
Sandbox& sbCancel, Sandbox& sbCancel,
Amounts const& takerAmount) Amounts const& takerAmount)
{ {
NetClock::time_point const when = ctx_.view().parentCloseTime(); NetClock::time_point const when = sb.parentCloseTime();
beast::WrappedSink takerSink(j_, "Taker "); beast::WrappedSink takerSink(j_, "Taker ");
@@ -957,7 +957,7 @@ CreateOffer::applyGuts(Sandbox& sb, Sandbox& sbCancel)
// Expiration is defined in terms of the close time of the parent ledger, // 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 // because we definitively know the time that it closed but we do not
// know the closing time of the ledger that is under construction. // 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 // If the offer has expired, the transaction has successfully
// done nothing, so short circuit from here. // done nothing, so short circuit from here.
@@ -965,13 +965,12 @@ CreateOffer::applyGuts(Sandbox& sb, Sandbox& sbCancel)
// The return code change is attached to featureDepositPreauth as a // The return code change is attached to featureDepositPreauth as a
// convenience. The change is not big enough to deserve a fix code. // convenience. The change is not big enough to deserve a fix code.
TER const ter{ TER const ter{
ctx_.view().rules().enabled(featureDepositPreauth) sb.rules().enabled(featureDepositPreauth) ? TER{tecEXPIRED}
? TER{tecEXPIRED} : TER{tesSUCCESS}};
: TER{tesSUCCESS}};
return {ter, true}; return {ter, true};
} }
bool const bOpenLedger = ctx_.view().open(); bool const bOpenLedger = sb.open();
bool crossed = false; bool crossed = false;
if (result == tesSUCCESS) if (result == tesSUCCESS)
@@ -1129,8 +1128,8 @@ CreateOffer::applyGuts(Sandbox& sb, Sandbox& sbCancel)
return {tefINTERNAL, false}; return {tefINTERNAL, false};
{ {
XRPAmount reserve = ctx_.view().fees().accountReserve( XRPAmount reserve =
sleCreator->getFieldU32(sfOwnerCount) + 1); sb.fees().accountReserve(sleCreator->getFieldU32(sfOwnerCount) + 1);
if (mPriorBalance < reserve) if (mPriorBalance < reserve)
{ {