mirror of
https://github.com/XRPLF/rippled.git
synced 2026-07-24 07:30:30 +00:00
Co-authored-by: tequ <git@tequ.dev> Co-authored-by: yinyiqian1 <yqian@ripple.com> Co-authored-by: Mayukha Vadari <mvadari@ripple.com> Co-authored-by: Mayukha Vadari <mvadari@gmail.com> Co-authored-by: xrplf-ai-reviewer[bot] <266832837+xrplf-ai-reviewer[bot]@users.noreply.github.com> Co-authored-by: Peter Chen <34582813+PeterChen13579@users.noreply.github.com> Co-authored-by: Zhiyuan Wang <96991820+Kassaking7@users.noreply.github.com> Co-authored-by: Ayaz Salikhov <asalikhov@ripple.com> Co-authored-by: Ayaz Salikhov <mathbunnyru@users.noreply.github.com> Co-authored-by: Zhiyuan Wang <1830604455@qq.com>
66 lines
1.9 KiB
C++
66 lines
1.9 KiB
C++
#include <xrpl/ledger/helpers/OfferHelpers.h>
|
|
|
|
#include <xrpl/basics/base_uint.h>
|
|
#include <xrpl/beast/utility/Journal.h>
|
|
#include <xrpl/beast/utility/instrumentation.h>
|
|
#include <xrpl/ledger/ApplyView.h>
|
|
#include <xrpl/ledger/helpers/AccountRootHelpers.h>
|
|
#include <xrpl/protocol/Indexes.h>
|
|
#include <xrpl/protocol/LedgerFormats.h> // IWYU pragma: keep
|
|
#include <xrpl/protocol/SField.h>
|
|
#include <xrpl/protocol/STArray.h> // IWYU pragma: keep
|
|
#include <xrpl/protocol/STLedgerEntry.h>
|
|
#include <xrpl/protocol/TER.h>
|
|
|
|
namespace xrpl {
|
|
|
|
TER
|
|
offerDelete(ApplyView& view, SLE::ref sle, beast::Journal j)
|
|
{
|
|
if (!sle)
|
|
return tesSUCCESS;
|
|
auto offerIndex = sle->key();
|
|
auto owner = sle->getAccountID(sfAccount);
|
|
|
|
// Detect legacy directories.
|
|
uint256 const uDirectory = sle->getFieldH256(sfBookDirectory);
|
|
|
|
if (!view.dirRemove(keylet::ownerDir(owner), sle->getFieldU64(sfOwnerNode), offerIndex, false))
|
|
{
|
|
return tefBAD_LEDGER; // LCOV_EXCL_LINE
|
|
}
|
|
|
|
if (!view.dirRemove(keylet::page(uDirectory), sle->getFieldU64(sfBookNode), offerIndex, false))
|
|
{
|
|
return tefBAD_LEDGER; // LCOV_EXCL_LINE
|
|
}
|
|
|
|
if (sle->isFieldPresent(sfAdditionalBooks))
|
|
{
|
|
XRPL_ASSERT(
|
|
sle->isFlag(lsfHybrid) && sle->isFieldPresent(sfDomainID),
|
|
"xrpl::offerDelete : should be a hybrid domain offer");
|
|
|
|
auto const& additionalBookDirs = sle->getFieldArray(sfAdditionalBooks);
|
|
|
|
for (auto const& bookDir : additionalBookDirs)
|
|
{
|
|
auto const& dirIndex = bookDir.getFieldH256(sfBookDirectory);
|
|
auto const& dirNode = bookDir.getFieldU64(sfBookNode);
|
|
|
|
if (!view.dirRemove(keylet::page(dirIndex), dirNode, offerIndex, false))
|
|
{
|
|
return tefBAD_LEDGER; // LCOV_EXCL_LINE
|
|
}
|
|
}
|
|
}
|
|
|
|
decreaseOwnerCountForObject(view, owner, sle, 1, j);
|
|
|
|
view.erase(sle);
|
|
|
|
return tesSUCCESS;
|
|
}
|
|
|
|
} // namespace xrpl
|