1#include <test/jtx/directory.h>
3#include <xrpl/ledger/Sandbox.h>
24 auto sleRoot = sb.
peek(directory);
32 auto const lastIndex = sleRoot->getFieldU64(sfIndexPrevious);
45 if (lastIndex >= newLastPage)
59 auto indexes = slePage->getFieldV256(sfIndexes);
60 auto prevIndex = slePage->at(~sfIndexPrevious);
61 auto owner = slePage->at(~sfOwner);
67 sleNew->setFieldH256(sfRootIndex, directory.
key);
68 sleNew->setFieldV256(sfIndexes, indexes);
70 sleNew->setAccountID(sfOwner, *owner);
72 sleNew->setFieldU64(sfIndexPrevious, *prevIndex);
76 sleRoot->setFieldU64(sfIndexPrevious, newLastPage);
77 if (prevIndex.value_or(0) == 0)
78 sleRoot->setFieldU64(sfIndexNext, newLastPage);
87 slePrev->setFieldU64(sfIndexNext, newLastPage);
94 for (
auto const key : indexes)
96 if (!adjust(sb, key, newLastPage))
114 if (sle && sle->isFieldPresent(sfOwnerNode))
116 sle->setFieldU64(sfOwnerNode, page);
A generic endpoint for log messages.
virtual OpenLedger & openLedger()=0
Writeable view to a ledger, for applying a transaction.
virtual void update(std::shared_ptr< SLE > const &sle)=0
Indicate changes to a peeked SLE.
virtual std::shared_ptr< SLE > peek(Keylet const &k)=0
Prepare to modify the SLE associated with key.
bool modify(modify_type const &f)
Modify the open ledger.
Writable ledger view that accumulates state and tx changes.
Discardable, editable view to a ledger.
void erase(std::shared_ptr< SLE > const &sle) override
Remove a peeked SLE.
void update(std::shared_ptr< SLE > const &sle) override
Indicate changes to a peeked SLE.
void insert(std::shared_ptr< SLE > const &sle) override
Insert a new state SLE.
bool exists(Keylet const &k) const override
Determine if a state item exists.
std::shared_ptr< SLE > peek(Keylet const &k) override
Prepare to modify the SLE associated with key.
A transaction testing environment.
Keylet page(uint256 const &root, std::uint64_t index=0) noexcept
A page in a directory.
auto bumpLastPage(Env &env, std::uint64_t newLastPage, Keylet directory, std::function< bool(ApplyView &, uint256, std::uint64_t)> adjust) -> Expected< void, Error >
Move the position of the last page in the user's directory on open ledger to newLastPage.
bool adjustOwnerNode(ApplyView &view, uint256 key, std::uint64_t page)
Implementation of adjust for the most common ledger entry, i.e.
@ ltANY
A special type, matching any ledger entry type.
A pair of SHAMap key and LedgerEntryType.