Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-merkledag
Commits
c20b9a52
Commit
c20b9a52
authored
Nov 19, 2019
by
Michael Muré
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sever the dependancy with go-path and interface-go-ipfs-core
parent
74471d62
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
21 additions
and
18 deletions
+21
-18
dagutils/diff.go
dagutils/diff.go
+6
-3
dagutils/diffenum.go
dagutils/diffenum.go
+2
-2
dagutils/diffenum_test.go
dagutils/diffenum_test.go
+3
-3
dagutils/utils.go
dagutils/utils.go
+5
-5
dagutils/utils_test.go
dagutils/utils_test.go
+5
-5
No files found.
dagutils/diff.go
View file @
c20b9a52
...
@@ -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
...
...
dagutils/diffenum.go
View file @
c20b9a52
...
@@ -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
...
...
dagutils/diffenum_test.go
View file @
c20b9a52
...
@@ -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
{
...
...
dagutils/utils.go
View file @
c20b9a52
...
@@ -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
...
...
dagutils/utils_test.go
View file @
c20b9a52
...
@@ -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
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment