Skip to content

Commit

Permalink
merkledag: Remove unused AddRecursive and RemoveRecursive
Browse files Browse the repository at this point in the history
License: MIT
Signed-off-by: Mildred Ki'Lya <mildred-pub.git@mildred.fr>
  • Loading branch information
mildred committed Feb 28, 2016
1 parent eeb27dc commit d2ec224
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 20 deletions.
8 changes: 6 additions & 2 deletions core/corehttp/gateway_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -454,15 +454,19 @@ func (i *gatewayHandler) deleteHandler(w http.ResponseWriter, r *http.Request) {

newnode := pathNodes[len(pathNodes)-1]
for i := len(pathNodes) - 2; i >= 0; i-- {
if err := i.node.DAG.Add(newnode); err != nil {
webError(w, "Could not add node", err, http.StatusInternalServerError)
return
}
newnode, err = pathNodes[i].UpdateNodeLink(components[i], newnode)
if err != nil {
webError(w, "Could not update node links", err, http.StatusInternalServerError)
return
}
}

if err := i.node.DAG.AddRecursive(newnode); err != nil {
webError(w, "Could not add recursively new node", err, http.StatusInternalServerError)
if err := i.node.DAG.Add(newnode); err != nil {
webError(w, "Could not add recursively root node", err, http.StatusInternalServerError)
return
}

Expand Down
15 changes: 0 additions & 15 deletions merkledag/merkledag.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ type DAGService interface {
AddRecursive(*Node) error
Get(context.Context, key.Key) (*Node, error)
Remove(*Node) error
RemoveRecursive(*Node) error

// GetDAG returns, in order, all the single leve child
// nodes of the passed in node.
Expand Down Expand Up @@ -107,20 +106,6 @@ func (n *dagService) Get(ctx context.Context, k key.Key) (*Node, error) {
return DecodeProtobuf(b.Data)
}

// Remove deletes the given node and all of its children from the BlockService
func (n *dagService) RemoveRecursive(nd *Node) error {
for _, l := range nd.Links {
if l.node != nil {
n.RemoveRecursive(l.node)
}
}
k, err := nd.Key()
if err != nil {
return err
}
return n.Blocks.DeleteBlock(k)
}

func (n *dagService) Remove(nd *Node) error {
k, err := nd.Key()
if err != nil {
Expand Down
8 changes: 5 additions & 3 deletions path/resolver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,11 @@ func TestRecurivePathResolution(t *testing.T) {
t.Fatal(err)
}

err = dagService.AddRecursive(a)
if err != nil {
t.Fatal(err)
for _, n := range []*Node{a, b, c} {
err = dagService.Add(n)
if err != nil {
t.Fatal(err)
}
}

aKey, err := a.Key()
Expand Down

0 comments on commit d2ec224

Please sign in to comment.