clean up OracleEntry

This commit is contained in:
Mayukha Vadari
2026-07-13 13:27:41 -04:00
parent cb2ab92927
commit d4cb62e78d
4 changed files with 62 additions and 55 deletions

View File

@@ -28,12 +28,10 @@ OracleDelete::preflight(PreflightContext const& ctx)
TER
OracleDelete::preclaim(PreclaimContext const& ctx)
{
if (!ctx.view.exists(keylet::account(ctx.tx.getAccountID(sfAccount))))
return terNO_ACCOUNT; // LCOV_EXCL_LINE
auto const sle = OracleEntry<ReadView>{
ctx.tx.getAccountID(sfAccount), ctx.tx[sfOracleDocumentID], ctx.view, ctx.j};
auto const sle =
ctx.view.read(keylet::oracle(ctx.tx.getAccountID(sfAccount), ctx.tx[sfOracleDocumentID]));
if (!sle)
if (!sle.exists())
{
JLOG(ctx.j.debug()) << "Oracle Delete: Oracle does not exist.";
return tecNO_ENTRY;
@@ -70,11 +68,11 @@ OracleDelete::deleteOracle(
TER
OracleDelete::doApply()
{
if (OracleEntry<ApplyView> sle{
keylet::oracle(accountID_, ctx_.tx[sfOracleDocumentID]), ctx_.view()})
return deleteOracle(ctx_.view(), sle.mutableSle(), accountID_, j_);
auto const sle = OracleEntry<ApplyView>{accountID_, ctx_.tx[sfOracleDocumentID], ctx_.view()};
if (!sle.exists())
return tecINTERNAL; // LCOV_EXCL_LINE
return tecINTERNAL; // LCOV_EXCL_LINE
return deleteOracle(ctx_.view(), sle.mutableSle(), accountID_, j_);
}
void

View File

@@ -85,7 +85,7 @@ OracleSet::preclaim(PreclaimContext const& ctx)
return tecINVALID_UPDATE_TIME;
OracleEntry<ReadView> sle{
keylet::oracle(ctx.tx.getAccountID(sfAccount), ctx.tx[sfOracleDocumentID]), ctx.view};
ctx.tx.getAccountID(sfAccount), ctx.tx[sfOracleDocumentID], ctx.view, ctx.j};
// token pairs to add/update
std::set<std::pair<Currency, Currency>> pairs;
@@ -154,7 +154,7 @@ OracleSet::preclaim(PreclaimContext const& ctx)
if (!pairsDel.empty())
return tecTOKEN_PAIR_NOT_FOUND;
auto const oldCount = calculateOracleReserve(sle.sle());
auto const oldCount = sle.reserveCount();
auto const newCount = calculateOracleReserve(pairs);
adjustReserve = newCount - oldCount;
@@ -217,8 +217,6 @@ setPriceDataInnerObjTemplate(STObject& obj)
TER
OracleSet::doApply()
{
auto const oracleID = keylet::oracle(accountID_, ctx_.tx[sfOracleDocumentID]);
auto populatePriceData = [](STObject& priceData, STObject const& entry) {
setPriceDataInnerObjTemplate(priceData);
priceData.setFieldCurrency(sfBaseAsset, entry.getFieldCurrency(sfBaseAsset));
@@ -228,7 +226,7 @@ OracleSet::doApply()
priceData.setFieldU8(sfScale, entry.getFieldU8(sfScale));
};
OracleEntry<ApplyView> sle{oracleID, ctx_.view()};
OracleEntry<ApplyView> sle{accountID_, ctx_.tx[sfOracleDocumentID], ctx_.view()};
if (sle)
{
// update