Merge remote-tracking branch 'XRPLF/develop' into ximinez/directory

* XRPLF/develop:
  fix: Fix regressions in `server_definitions` (7008)
  chore: Do not duplicate sanitizer flags (7058)
  ci: Run pre-commit on diff in clang-tidy workflow (7078)
  ci: Use XRPLF/create-issue (7076)
  ci: Rewrite clang-tidy workflow(s) in a reusable manner (7062)
  chore: Ignore identifier-naming update in git blame (7066)
  refactor: Enable clang-tidy `readability-identifier-naming` check (6571)
This commit is contained in:
Ed Hennis
2026-05-05 16:44:42 -04:00
1508 changed files with 59256 additions and 59456 deletions

View File

@@ -46,7 +46,7 @@ createRoot(
describe(newRoot);
STVector256 v;
v.push_back(key);
v.pushBack(key);
newRoot->setFieldV256(sfIndexes, v);
view.insert(newRoot);
@@ -88,7 +88,7 @@ insertKey(
if (std::ranges::find(indexes, key) != indexes.end())
Throw<std::logic_error>("dirInsert: double insertion"); // LCOV_EXCL_LINE
indexes.push_back(key);
indexes.pushBack(key);
}
else
{
@@ -133,7 +133,7 @@ insertPage(
// Check whether we're out of pages.
if (page == 0)
return std::nullopt;
if (!view.rules().enabled(fixDirectoryLimit) && page >= dirNodeMaxPages) // Old pages limit
if (!view.rules().enabled(fixDirectoryLimit) && page >= kDIR_NODE_MAX_PAGES) // Old pages limit
{
return std::nullopt;
}
@@ -148,7 +148,7 @@ insertPage(
// Insert the new key:
STVector256 indexes;
indexes.push_back(key);
indexes.pushBack(key);
node = std::make_shared<SLE>(keylet::page(directory, page));
node->setFieldH256(sfRootIndex, directory.key);
@@ -190,7 +190,7 @@ ApplyView::dirAdd(
// the last one, walk backwards to find one with space, or to find one
// missing.
std::optional<directory::Gap> gapPages;
while (page && indexes.size() >= dirNodeMaxEntries)
while (page && indexes.size() >= kDIR_NODE_MAX_PAGES)
{
// Find a page with space, or a gap in pages.
auto [prevPage, prevNode, prevIndexes] =
@@ -222,7 +222,7 @@ ApplyView::dirAdd(
}
// If there's space, we use it:
if (indexes.size() < dirNodeMaxEntries)
if (indexes.size() < kDIR_NODE_MAX_ENTRIES)
{
return directory::insertKey(*this, node, page, preserveOrder, indexes, key);
}
@@ -251,19 +251,19 @@ ApplyView::emptyDirDelete(Keylet const& directory)
if (!node->getFieldV256(sfIndexes).empty())
return false;
std::uint64_t constexpr rootPage = 0;
std::uint64_t constexpr kROOT_PAGE = 0;
auto prevPage = node->getFieldU64(sfIndexPrevious);
auto nextPage = node->getFieldU64(sfIndexNext);
if (nextPage == rootPage && prevPage != rootPage)
if (nextPage == kROOT_PAGE && prevPage != kROOT_PAGE)
Throw<std::logic_error>("Directory chain: fwd link broken"); // LCOV_EXCL_LINE
if (prevPage == rootPage && nextPage != rootPage)
if (prevPage == kROOT_PAGE && nextPage != kROOT_PAGE)
Throw<std::logic_error>("Directory chain: rev link broken"); // LCOV_EXCL_LINE
// Older versions of the code would, in some cases, allow the last page to
// be empty. Remove such pages:
if (nextPage == prevPage && nextPage != rootPage)
// Older versions of the code would, in some cases, allow the last
// page to be empty. Remove such pages:
if (nextPage == prevPage && nextPage != kROOT_PAGE)
{
auto last = peek(keylet::page(directory, nextPage));
@@ -273,21 +273,23 @@ ApplyView::emptyDirDelete(Keylet const& directory)
if (!last->getFieldV256(sfIndexes).empty())
return false;
// Update the first page's linked list and mark it as updated.
node->setFieldU64(sfIndexNext, rootPage);
node->setFieldU64(sfIndexPrevious, rootPage);
// Update the first page's linked list and
// mark it as updated.
node->setFieldU64(sfIndexNext, kROOT_PAGE);
node->setFieldU64(sfIndexPrevious, kROOT_PAGE);
update(node);
// And erase the empty last page:
erase(last);
// Make sure our local values reflect the updated information:
nextPage = rootPage;
prevPage = rootPage;
// Make sure our local values reflect the
// updated information:
nextPage = kROOT_PAGE;
prevPage = kROOT_PAGE;
}
// If there are no other pages, erase the root:
if (nextPage == rootPage && prevPage == rootPage)
if (nextPage == kROOT_PAGE && prevPage == kROOT_PAGE)
erase(node);
return true;
@@ -301,7 +303,7 @@ ApplyView::dirRemove(Keylet const& directory, std::uint64_t page, uint256 const&
if (!node)
return false;
std::uint64_t constexpr rootPage = 0;
std::uint64_t constexpr kROOT_PAGE = 0;
{
auto entries = node->getFieldV256(sfIndexes);
@@ -326,10 +328,11 @@ ApplyView::dirRemove(Keylet const& directory, std::uint64_t page, uint256 const&
auto prevPage = node->getFieldU64(sfIndexPrevious);
auto nextPage = node->getFieldU64(sfIndexNext);
// The first page is the directory's root node and is treated specially: it
// can never be deleted even if it is empty, unless we plan on removing the
// entire directory.
if (page == rootPage)
// The first page is the directory's root node and is
// treated specially: it can never be deleted even if
// it is empty, unless we plan on removing the entire
// directory.
if (page == kROOT_PAGE)
{
if (nextPage == page && prevPage != page)
Throw<std::logic_error>("Directory chain: fwd link broken"); // LCOV_EXCL_LINE
@@ -398,32 +401,32 @@ ApplyView::dirRemove(Keylet const& directory, std::uint64_t page, uint256 const&
// The page is no longer linked. Delete it.
erase(node);
// Check whether the next page is the last page and, if so, whether it's
// empty. If it is, delete it.
if (nextPage != rootPage && next->getFieldU64(sfIndexNext) == rootPage &&
// Check whether the next page is the last page and, if
// so, whether it's empty. If it is, delete it.
if (nextPage != kROOT_PAGE && next->getFieldU64(sfIndexNext) == kROOT_PAGE &&
next->getFieldV256(sfIndexes).empty())
{
// Since next doesn't point to the root, it can't be pointing to prev.
erase(next);
// The previous page is now the last page:
prev->setFieldU64(sfIndexNext, rootPage);
prev->setFieldU64(sfIndexNext, kROOT_PAGE);
update(prev);
// And the root points to the last page:
auto root = peek(keylet::page(directory, rootPage));
auto root = peek(keylet::page(directory, kROOT_PAGE));
if (!root)
Throw<std::logic_error>("Directory chain: root link broken."); // LCOV_EXCL_LINE
root->setFieldU64(sfIndexPrevious, prevPage);
update(root);
nextPage = rootPage;
nextPage = kROOT_PAGE;
}
// If we're not keeping the root, then check to see if it's left empty.
// If so, delete it as well.
if (!keepRoot && nextPage == rootPage && prevPage == rootPage)
// If we're not keeping the root, then check to see if
// it's left empty. If so, delete it as well.
if (!keepRoot && nextPage == kROOT_PAGE && prevPage == kROOT_PAGE)
{
if (prev->getFieldV256(sfIndexes).empty())
erase(prev);