refactor: Avoid throwing in visitNodes when a node is evicted during rotation

This commit is contained in:
Bart
2026-05-29 13:58:28 -04:00
parent 2f3558c610
commit 9c607cbd50
2 changed files with 7 additions and 4 deletions

View File

@@ -325,9 +325,6 @@ SHAMap::descend(SHAMapInnerNode& parent, int branch) const
return node;
node = fetchNode(parent.getChildHash(branch));
if (!node)
return {};
node = parent.canonicalizeChild(branch, std::move(node));
return node;
}
@@ -339,7 +336,7 @@ SHAMap::descendNoStore(SHAMapInnerNode& parent, int branch) const
{
intr_ptr::SharedPtr<SHAMapTreeNode> ret = parent.getChild(branch);
if (!ret && backed_)
ret = fetchNode(parent.getChildHash(branch));
ret = fetchNodeNT(parent.getChildHash(branch));
return ret;
}

View File

@@ -67,6 +67,12 @@ SHAMap::visitNodes(std::function<bool(SHAMapTreeNode&)> const& function) const
if (!node->isEmptyBranch(pos))
{
intr_ptr::SharedPtr<SHAMapTreeNode> const child = descendNoStore(*node, pos);
if (!child)
{
// Node was evicted after rotation; skip this subtree.
++pos;
continue;
}
if (!function(*child))
return;