Skip to content

Commit 1826896

Browse files
authored
fix(trie): descendants count for clear prefix (#2606)
1 parent 2a6fa83 commit 1826896

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/trie/trie.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -877,10 +877,11 @@ func (t *Trie) clearPrefix(parent *Node, prefix []byte) (
877877
return parent, nodesRemoved
878878
}
879879

880-
nodesRemoved = 1
880+
nodesRemoved = 1 + child.Descendants
881881
copySettings := node.DefaultCopySettings
882882
branch = t.prepBranchForMutation(branch, copySettings)
883883
branch.Children[childIndex] = nil
884+
branch.Descendants -= nodesRemoved
884885
var branchChildMerged bool
885886
newParent, branchChildMerged = handleDeletion(branch, prefix)
886887
if branchChildMerged {

0 commit comments

Comments
 (0)