mirror of
https://github.com/XRPLF/rippled.git
synced 2026-06-03 00:36:48 +00:00
refactor: Avoid throwing in visitNodes when a node is evicted during rotation
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user