Skip to content

Commit

Permalink
sever the dependancy with go-path and interface-go-ipfs-core
Browse files Browse the repository at this point in the history
This commit was moved from ipfs/go-merkledag@c20b9a5
  • Loading branch information
MichaelMure committed Nov 19, 2019
1 parent ae98646 commit 502aa44
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 18 deletions.
9 changes: 6 additions & 3 deletions ipld/merkledag/dagutils/diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,24 @@ import (

"github.com/ipfs/go-cid"
ipld "github.com/ipfs/go-ipld-format"

dag "github.com/ipfs/go-merkledag"
coreiface "github.com/ipfs/interface-go-ipfs-core"
)

// ChangeType denotes type of change in Change
type ChangeType int

// These constants define the changes that can be applied to a DAG.
const (
Add = iota
Add ChangeType = iota
Remove
Mod
)

// Change represents a change to a DAG and contains a reference to the old and
// new CIDs.
type Change struct {
Type coreiface.ChangeType
Type ChangeType
Path string
Before cid.Cid
After cid.Cid
Expand Down
4 changes: 2 additions & 2 deletions ipld/merkledag/dagutils/diffenum.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import (
"context"
"fmt"

mdag "github.com/ipfs/go-merkledag"

cid "github.com/ipfs/go-cid"
ipld "github.com/ipfs/go-ipld-format"

mdag "github.com/ipfs/go-merkledag"
)

// DiffEnumerate fetches every object in the graph pointed to by 'to' that is
Expand Down
6 changes: 3 additions & 3 deletions ipld/merkledag/dagutils/diffenum_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import (
"fmt"
"testing"

"github.com/ipfs/go-cid"
ipld "github.com/ipfs/go-ipld-format"

dag "github.com/ipfs/go-merkledag"
mdtest "github.com/ipfs/go-merkledag/test"

cid "github.com/ipfs/go-cid"
ipld "github.com/ipfs/go-ipld-format"
)

func buildNode(name string, desc map[string]ndesc, out map[string]ipld.Node) ipld.Node {
Expand Down
10 changes: 5 additions & 5 deletions ipld/merkledag/dagutils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ package dagutils
import (
"context"
"errors"
"strings"

bserv "github.com/ipfs/go-blockservice"
dag "github.com/ipfs/go-merkledag"
path "github.com/ipfs/go-path"

ds "github.com/ipfs/go-datastore"
syncds "github.com/ipfs/go-datastore/sync"
bstore "github.com/ipfs/go-ipfs-blockstore"
offline "github.com/ipfs/go-ipfs-exchange-offline"
ipld "github.com/ipfs/go-ipld-format"

dag "github.com/ipfs/go-merkledag"
)

// Editor represents a ProtoNode tree editor and provides methods to
Expand Down Expand Up @@ -87,7 +87,7 @@ func addLink(ctx context.Context, ds ipld.DAGService, root *dag.ProtoNode, child

// InsertNodeAtPath inserts a new node in the tree and replaces the current root with the new one.
func (e *Editor) InsertNodeAtPath(ctx context.Context, pth string, toinsert ipld.Node, create func() *dag.ProtoNode) error {
splpath := path.SplitList(pth)
splpath := strings.Split(pth, "/")
nd, err := e.insertNodeAtPath(ctx, e.root, splpath, toinsert, create)
if err != nil {
return err
Expand Down Expand Up @@ -143,7 +143,7 @@ func (e *Editor) insertNodeAtPath(ctx context.Context, root *dag.ProtoNode, path
// RmLink removes the link with the given name and updates the root node of
// the editor.
func (e *Editor) RmLink(ctx context.Context, pth string) error {
splpath := path.SplitList(pth)
splpath := strings.Split(pth, "/")
nd, err := e.rmLink(ctx, e.root, splpath)
if err != nil {
return err
Expand Down
10 changes: 5 additions & 5 deletions ipld/merkledag/dagutils/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ package dagutils

import (
"context"
"strings"
"testing"

"github.com/ipfs/go-cid"
ipld "github.com/ipfs/go-ipld-format"

dag "github.com/ipfs/go-merkledag"
mdtest "github.com/ipfs/go-merkledag/test"
path "github.com/ipfs/go-path"

cid "github.com/ipfs/go-cid"
ipld "github.com/ipfs/go-ipld-format"
)

func TestAddLink(t *testing.T) {
Expand Down Expand Up @@ -42,7 +42,7 @@ func TestAddLink(t *testing.T) {
}

func assertNodeAtPath(t *testing.T, ds ipld.DAGService, root *dag.ProtoNode, pth string, exp cid.Cid) {
parts := path.SplitList(pth)
parts := strings.Split(pth, "/")
cur := root
for _, e := range parts {
nxt, err := cur.GetLinkedProtoNode(context.Background(), ds, e)
Expand Down

0 comments on commit 502aa44

Please sign in to comment.