diff --git a/deepsubtree.go b/deepsubtree.go index 9e561edd8..1c71a97b3 100644 --- a/deepsubtree.go +++ b/deepsubtree.go @@ -250,7 +250,9 @@ func (dst *DeepSubTree) recursiveSet(node *Node, key []byte, value []byte) ( return nil, false, err } orphans := dst.prepareOrphansSlice() + node.persisted = false newNode, err := dst.balance(node, &orphans) + node.persisted = true if err != nil { return nil, false, err } diff --git a/deepsubtree_test.go b/deepsubtree_test.go index bcad4dce8..53afe8009 100644 --- a/deepsubtree_test.go +++ b/deepsubtree_test.go @@ -148,7 +148,7 @@ func TestDeepSubtreeWWithAddsAndDeletes(t *testing.T) { fmt.Println("PRINT TREE END") subsetKeys := [][]byte{ - []byte("b"), + []byte("a"), []byte("b"), } rootHash := tree.root.hash mutableTree, err := NewMutableTree(db.NewMemDB(), 100, false) @@ -164,31 +164,31 @@ func TestDeepSubtreeWWithAddsAndDeletes(t *testing.T) { // Add exclusion proof for `c` keyToAdd := []byte("c") valueToAdd := []byte{3} - nonInclusionProof, err := tree.GetNonMembershipProof(keyToAdd) - require.NoError(err) - nonExist := nonInclusionProof.GetNonexist() - leftNonExist := nonExist.Left - if leftNonExist != nil { - leftKey := leftNonExist.Key - if has, _ := dst.Has(leftKey); !has { - err = dst.AddPath(tree.ImmutableTree, leftKey) - require.NoError(err) - dst.BuildTree(rootHash) - require.NoError(err) - } - // TODO: Add sibling node to dst - } - rightNonExist := nonExist.Right - if rightNonExist != nil { - rightKey := rightNonExist.Key - if has, _ := dst.Has(rightKey); !has { - err = dst.AddPath(tree.ImmutableTree, rightKey) - require.NoError(err) - dst.BuildTree(rootHash) - require.NoError(err) - } - // TODO: Add sibling node to dst - } + // nonInclusionProof, err := tree.GetNonMembershipProof(keyToAdd) + // require.NoError(err) + // nonExist := nonInclusionProof.GetNonexist() + // leftNonExist := nonExist.Left + // if leftNonExist != nil { + // leftKey := leftNonExist.Key + // if has, _ := dst.Has(leftKey); !has { + // err = dst.AddPath(tree.ImmutableTree, leftKey) + // require.NoError(err) + // dst.BuildTree(rootHash) + // require.NoError(err) + // } + // // TODO: Add sibling node to dst + // } + // rightNonExist := nonExist.Right + // if rightNonExist != nil { + // rightKey := rightNonExist.Key + // if has, _ := dst.Has(rightKey); !has { + // err = dst.AddPath(tree.ImmutableTree, rightKey) + // require.NoError(err) + // dst.BuildTree(rootHash) + // require.NoError(err) + // } + // // TODO: Add sibling node to dst + // } dst.SaveVersion()