Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added some more traces related to deletion #7

Merged
merged 1 commit into from
Feb 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion src/trie_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,10 @@ fn delete_intern<N: PartialTrie>(
children, nibble,
);

trace!("Branch {:x} became an extension when collapsing a branch (may be collapsed further still).
Single remaining child in slot {:x} ({}) will be pointed at with an extension node.",
nibble, child_nibble, TrieNodeType::from(non_empty_node.deref()));

// Extension may be collapsed one level above.
extension(Nibbles::from_nibble(child_nibble), non_empty_node.clone())
}
Expand Down Expand Up @@ -516,7 +520,10 @@ fn delete_intern<N: PartialTrie>(
}
Node::Leaf { nibbles, value } => {
trace!("Delete traversed Leaf (nibbles: {:?})", nibbles);
(*nibbles == curr_k).then(|| (Node::Empty.into(), value.clone()))
(*nibbles == curr_k).then(|| {
trace!("Deleting leaf ({:x})", nibbles);
(Node::Empty.into(), value.clone())
})
}
}
}
Expand All @@ -532,6 +539,12 @@ fn collapse_ext_node_if_needed<N: PartialTrie>(
ext_nibbles: &Nibbles,
child: &WrappedNode<N>,
) -> WrappedNode<N> {
trace!(
"Collapsing extension node ({:x}) with child {}...",
ext_nibbles,
TrieNodeType::from(child.deref())
);

match child.as_ref() {
Node::Branch { .. } => extension(*ext_nibbles, child.clone()),
Node::Extension {
Expand Down