From e6564f553da05dfbd1b2b82ae21c2997db99de9e Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Tue, 6 Oct 2026 14:23:24 +0000 Subject: [PATCH] refactor: Use NegativeUNLEntry everywhere (#8365) --- src/libxrpl/ledger/Ledger.cpp | 8 +++++--- src/libxrpl/tx/transactors/system/Change.cpp | 10 +++++----- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/libxrpl/ledger/Ledger.cpp b/src/libxrpl/ledger/Ledger.cpp index 7eae398f94..e8bbcb9e32 100644 --- a/src/libxrpl/ledger/Ledger.cpp +++ b/src/libxrpl/ledger/Ledger.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -640,7 +641,7 @@ HashSet Ledger::negativeUNL() const { HashSet negUnl; - if (auto sle = read(keylet::negativeUNL()); sle && sle->isFieldPresent(sfDisabledValidators)) + if (auto const sle = NegativeUNLEntryR(*this); sle && sle->isFieldPresent(sfDisabledValidators)) { auto const& nUnlData = sle->getFieldArray(sfDisabledValidators); for (auto const& n : nUnlData) @@ -664,7 +665,7 @@ Ledger::negativeUNL() const std::optional Ledger::validatorToDisable() const { - if (auto sle = read(keylet::negativeUNL()); sle && sle->isFieldPresent(sfValidatorToDisable)) + if (auto const sle = NegativeUNLEntryR(*this); sle && sle->isFieldPresent(sfValidatorToDisable)) { auto d = sle->getFieldVL(sfValidatorToDisable); auto s = makeSlice(d); @@ -678,7 +679,8 @@ Ledger::validatorToDisable() const std::optional Ledger::validatorToReEnable() const { - if (auto sle = read(keylet::negativeUNL()); sle && sle->isFieldPresent(sfValidatorToReEnable)) + if (auto const sle = NegativeUNLEntryR(*this); + sle && sle->isFieldPresent(sfValidatorToReEnable)) { auto d = sle->getFieldVL(sfValidatorToReEnable); auto s = makeSlice(d); diff --git a/src/libxrpl/tx/transactors/system/Change.cpp b/src/libxrpl/tx/transactors/system/Change.cpp index 4e56e7d933..d75fd185e0 100644 --- a/src/libxrpl/tx/transactors/system/Change.cpp +++ b/src/libxrpl/tx/transactors/system/Change.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -331,12 +332,11 @@ Change::applyUNLModify() JLOG(j_.info()) << "N-UNL: applyUNLModify, " << (disabling ? "ToDisable" : "ToReEnable") << " seq=" << seq << " validator data:" << strHex(validator); - auto const k = keylet::negativeUNL(); - SLE::pointer negUnlObject = view().peek(k); + NegativeUNLEntryW negUnlObject(view(), j_); if (!negUnlObject) { - negUnlObject = std::make_shared(k); - view().insert(negUnlObject); + negUnlObject.newSLE(); + negUnlObject.insert(); } bool const found = [&] { @@ -409,7 +409,7 @@ Change::applyUNLModify() negUnlObject->setFieldVL(sfValidatorToReEnable, validator); } - view().update(negUnlObject); + negUnlObject.update(); return tesSUCCESS; }