Commit c20b9a52 authored by Michael Muré's avatar Michael Muré

sever the dependancy with go-path and interface-go-ipfs-core

parent 74471d62
...@@ -7,13 +7,16 @@ import ( ...@@ -7,13 +7,16 @@ import (
"github.com/ipfs/go-cid" "github.com/ipfs/go-cid"
ipld "github.com/ipfs/go-ipld-format" ipld "github.com/ipfs/go-ipld-format"
dag "github.com/ipfs/go-merkledag" 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. // These constants define the changes that can be applied to a DAG.
const ( const (
Add = iota Add ChangeType = iota
Remove Remove
Mod Mod
) )
...@@ -21,7 +24,7 @@ const ( ...@@ -21,7 +24,7 @@ const (
// Change represents a change to a DAG and contains a reference to the old and // Change represents a change to a DAG and contains a reference to the old and
// new CIDs. // new CIDs.
type Change struct { type Change struct {
Type coreiface.ChangeType Type ChangeType
Path string Path string
Before cid.Cid Before cid.Cid
After cid.Cid After cid.Cid
......
...@@ -4,10 +4,10 @@ import ( ...@@ -4,10 +4,10 @@ import (
"context" "context"
"fmt" "fmt"
mdag "github.com/ipfs/go-merkledag"
cid "github.com/ipfs/go-cid" cid "github.com/ipfs/go-cid"
ipld "github.com/ipfs/go-ipld-format" 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 // DiffEnumerate fetches every object in the graph pointed to by 'to' that is
......
...@@ -5,11 +5,11 @@ import ( ...@@ -5,11 +5,11 @@ import (
"fmt" "fmt"
"testing" "testing"
"github.com/ipfs/go-cid"
ipld "github.com/ipfs/go-ipld-format"
dag "github.com/ipfs/go-merkledag" dag "github.com/ipfs/go-merkledag"
mdtest "github.com/ipfs/go-merkledag/test" 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 { func buildNode(name string, desc map[string]ndesc, out map[string]ipld.Node) ipld.Node {
......
...@@ -3,16 +3,16 @@ package dagutils ...@@ -3,16 +3,16 @@ package dagutils
import ( import (
"context" "context"
"errors" "errors"
"strings"
bserv "github.com/ipfs/go-blockservice" bserv "github.com/ipfs/go-blockservice"
dag "github.com/ipfs/go-merkledag"
path "github.com/ipfs/go-path"
ds "github.com/ipfs/go-datastore" ds "github.com/ipfs/go-datastore"
syncds "github.com/ipfs/go-datastore/sync" syncds "github.com/ipfs/go-datastore/sync"
bstore "github.com/ipfs/go-ipfs-blockstore" bstore "github.com/ipfs/go-ipfs-blockstore"
offline "github.com/ipfs/go-ipfs-exchange-offline" offline "github.com/ipfs/go-ipfs-exchange-offline"
ipld "github.com/ipfs/go-ipld-format" ipld "github.com/ipfs/go-ipld-format"
dag "github.com/ipfs/go-merkledag"
) )
// Editor represents a ProtoNode tree editor and provides methods to // Editor represents a ProtoNode tree editor and provides methods to
...@@ -87,7 +87,7 @@ func addLink(ctx context.Context, ds ipld.DAGService, root *dag.ProtoNode, child ...@@ -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. // 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 { 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) nd, err := e.insertNodeAtPath(ctx, e.root, splpath, toinsert, create)
if err != nil { if err != nil {
return err return err
...@@ -143,7 +143,7 @@ func (e *Editor) insertNodeAtPath(ctx context.Context, root *dag.ProtoNode, path ...@@ -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 // RmLink removes the link with the given name and updates the root node of
// the editor. // the editor.
func (e *Editor) RmLink(ctx context.Context, pth string) error { 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) nd, err := e.rmLink(ctx, e.root, splpath)
if err != nil { if err != nil {
return err return err
......
...@@ -2,14 +2,14 @@ package dagutils ...@@ -2,14 +2,14 @@ package dagutils
import ( import (
"context" "context"
"strings"
"testing" "testing"
"github.com/ipfs/go-cid"
ipld "github.com/ipfs/go-ipld-format"
dag "github.com/ipfs/go-merkledag" dag "github.com/ipfs/go-merkledag"
mdtest "github.com/ipfs/go-merkledag/test" 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) { func TestAddLink(t *testing.T) {
...@@ -42,7 +42,7 @@ func TestAddLink(t *testing.T) { ...@@ -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) { 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 cur := root
for _, e := range parts { for _, e := range parts {
nxt, err := cur.GetLinkedProtoNode(context.Background(), ds, e) nxt, err := cur.GetLinkedProtoNode(context.Background(), ds, e)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment