1#include <xrpl/ledger/helpers/DirectoryHelpers.h>
3#include <xrpl/protocol/LedgerFormats.h>
57 XRPL_ASSERT(
root.type == ltDIR_NODE,
"xrpl::forEachItem : valid root type");
59 if (
root.type != ltDIR_NODE)
66 auto sle = view.
read(pos);
69 for (
auto const& key : sle->getFieldV256(sfIndexes))
71 auto const next = sle->getFieldU64(sfIndexNext);
87 XRPL_ASSERT(
root.type == ltDIR_NODE,
"xrpl::forEachItemAfter : valid root type");
89 if (
root.type != ltDIR_NODE)
92 auto currentIndex =
root;
95 if (
after.isNonZero())
99 if (
auto hintDir = view.
read(hintIndex))
101 for (
auto const& key : hintDir->getFieldV256(sfIndexes))
106 currentIndex = hintIndex;
115 auto const ownerDir = view.
read(currentIndex);
118 for (
auto const& key : ownerDir->getFieldV256(sfIndexes))
131 auto const uNodeNext = ownerDir->getFieldU64(sfIndexNext);
141 auto const ownerDir = view.
read(currentIndex);
144 for (
auto const& key : ownerDir->getFieldV256(sfIndexes))
149 auto const uNodeNext = ownerDir->getFieldU64(sfIndexNext);
160 auto const sleNode = view.
read(k);
163 if (!sleNode->getFieldV256(sfIndexes).empty())
168 return sleNode->getFieldU64(sfIndexNext) == 0;
Writeable view to a ledger, for applying a transaction.
virtual std::shared_ptr< SLE const > read(Keylet const &k) const =0
Return the state item associated with a key.
std::shared_ptr< STLedgerEntry > const & ref
bool internalDirFirst(V &view, uint256 const &root, std::shared_ptr< N > &page, unsigned int &index, uint256 &entry)
bool internalDirNext(V &view, uint256 const &root, std::shared_ptr< N > &page, unsigned int &index, uint256 &entry)
Keylet child(uint256 const &key) noexcept
Any item that can be in an owner dir.
Keylet page(uint256 const &root, std::uint64_t index=0) noexcept
A page in a directory.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
bool dirFirst(ApplyView &view, uint256 const &root, std::shared_ptr< SLE > &page, unsigned int &index, uint256 &entry)
bool dirIsEmpty(ReadView const &view, Keylet const &k)
Returns true if the directory is empty.
void forEachItem(ReadView const &view, Keylet const &root, std::function< void(std::shared_ptr< SLE const > const &)> const &f)
Iterate all items in the given directory.
Number root(Number f, unsigned d)
bool cdirNext(ReadView const &view, uint256 const &root, std::shared_ptr< SLE const > &page, unsigned int &index, uint256 &entry)
Returns the next entry in the directory, advancing the index.
bool cdirFirst(ReadView const &view, uint256 const &root, std::shared_ptr< SLE const > &page, unsigned int &index, uint256 &entry)
Returns the first entry in the directory, advancing the index.
bool after(NetClock::time_point now, std::uint32_t mark)
Has the specified time passed?
std::function< void(SLE::ref)> describeOwnerDir(AccountID const &account)
Returns a function that sets the owner on a directory SLE.
bool forEachItemAfter(ReadView const &view, Keylet const &root, uint256 const &after, std::uint64_t const hint, unsigned int limit, std::function< bool(std::shared_ptr< SLE const > const &)> const &f)
Iterate all items after an item in the given directory.
bool dirNext(ApplyView &view, uint256 const &root, std::shared_ptr< SLE > &page, unsigned int &index, uint256 &entry)
A pair of SHAMap key and LedgerEntryType.