Skip to content

Commit

Permalink
shardtree: Fix pruning of annotated Parent nodes with Nil children.
Browse files Browse the repository at this point in the history
The current behavior of `unite` incorrectly discards annotation data.
  • Loading branch information
nuttycom committed Jun 27, 2024
1 parent 08d3e23 commit f5adcd5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions shardtree/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ and this project adheres to Rust's notion of
- Fixes an error that could occur if an inserted `Frontier` node was
interpreted as a node that had actually had its value observed as though it
had been inserted using the ordinary tree insertion methods.
- Fixes an error in an internal method that could result in subtree root
annotation data being discarded when pruning a `Parent` node having
`Nil` nodes for both its left and right children.

## [0.3.1] - 2024-04-03

Expand Down
2 changes: 1 addition & 1 deletion shardtree/src/prunable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ impl<H: Hashable + Clone + PartialEq> PrunableTree<H> {
/// `level` must be the level of the two nodes that are being joined.
pub(crate) fn unite(level: Level, ann: Option<Arc<H>>, left: Self, right: Self) -> Self {
match (left, right) {
(Tree(Node::Nil), Tree(Node::Nil)) => Tree::empty(),
(Tree(Node::Nil), Tree(Node::Nil)) if ann.is_none() => Tree::empty(),
(Tree(Node::Leaf { value: lv }), Tree(Node::Leaf { value: rv }))
// we can prune right-hand leaves that are not marked or reference leaves; if a
// leaf is a checkpoint then that information will be propagated to the replacement
Expand Down

0 comments on commit f5adcd5

Please sign in to comment.