shardtree: `Nil` nodes cannot replace any other sort of node in the tree.
This commit is contained in:
parent
811d384bd4
commit
57b6e8999f
|
@ -547,6 +547,16 @@ impl<H: Hashable + Clone + PartialEq> LocatedPrunableTree<H> {
|
||||||
is_complete: bool,
|
is_complete: bool,
|
||||||
contains_marked: bool,
|
contains_marked: bool,
|
||||||
) -> Result<(PrunableTree<H>, Vec<IncompleteAt>), InsertionError> {
|
) -> Result<(PrunableTree<H>, Vec<IncompleteAt>), InsertionError> {
|
||||||
|
trace!(
|
||||||
|
root_addr = ?root_addr,
|
||||||
|
max_position = ?LocatedTree::max_position_internal(root_addr, into),
|
||||||
|
to_insert = ?subtree.root_addr(),
|
||||||
|
"Subtree insert"
|
||||||
|
);
|
||||||
|
// An empty tree cannot replace any other type of tree.
|
||||||
|
if subtree.root().is_nil() {
|
||||||
|
Ok((into.clone(), vec![]))
|
||||||
|
} else {
|
||||||
// In the case that we are replacing a node entirely, we need to extend the
|
// In the case that we are replacing a node entirely, we need to extend the
|
||||||
// subtree up to the level of the node being replaced, adding Nil siblings
|
// subtree up to the level of the node being replaced, adding Nil siblings
|
||||||
// and recording the presence of those incomplete nodes when necessary
|
// and recording the presence of those incomplete nodes when necessary
|
||||||
|
@ -578,12 +588,6 @@ impl<H: Hashable + Clone + PartialEq> LocatedPrunableTree<H> {
|
||||||
(node.root.reannotate_root(ann), incomplete)
|
(node.root.reannotate_root(ann), incomplete)
|
||||||
};
|
};
|
||||||
|
|
||||||
trace!(
|
|
||||||
root_addr = ?root_addr,
|
|
||||||
max_position = ?LocatedTree::max_position_internal(root_addr, into),
|
|
||||||
to_insert = ?subtree.root_addr(),
|
|
||||||
"Subtree insert"
|
|
||||||
);
|
|
||||||
match into {
|
match into {
|
||||||
Tree(Node::Nil) => Ok(replacement(None, subtree)),
|
Tree(Node::Nil) => Ok(replacement(None, subtree)),
|
||||||
Tree(Node::Leaf { value: (value, _) }) => {
|
Tree(Node::Leaf { value: (value, _) }) => {
|
||||||
|
@ -599,7 +603,7 @@ impl<H: Hashable + Clone + PartialEq> LocatedPrunableTree<H> {
|
||||||
vec![],
|
vec![],
|
||||||
))
|
))
|
||||||
} else {
|
} else {
|
||||||
trace!(
|
warn!(
|
||||||
cur_root = ?value,
|
cur_root = ?value,
|
||||||
new_root = ?subtree.root.node_value(),
|
new_root = ?subtree.root.node_value(),
|
||||||
"Insertion conflict",
|
"Insertion conflict",
|
||||||
|
@ -656,6 +660,7 @@ impl<H: Hashable + Clone + PartialEq> LocatedPrunableTree<H> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let max_position = self.max_position();
|
let max_position = self.max_position();
|
||||||
trace!(
|
trace!(
|
||||||
|
|
Loading…
Reference in New Issue