From ba34a11ef5b85eb476cd400caf61c458d1b178c8 Mon Sep 17 00:00:00 2001 From: BGluth Date: Mon, 5 Feb 2024 12:26:08 -0700 Subject: [PATCH] Added some more traces related to deletion --- src/trie_ops.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/trie_ops.rs b/src/trie_ops.rs index 93f65eb..24f78a0 100644 --- a/src/trie_ops.rs +++ b/src/trie_ops.rs @@ -488,6 +488,10 @@ fn delete_intern( 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()) } @@ -516,7 +520,10 @@ fn delete_intern( } 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()) + }) } } } @@ -532,6 +539,12 @@ fn collapse_ext_node_if_needed( ext_nibbles: &Nibbles, child: &WrappedNode, ) -> WrappedNode { + 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 {