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-ld-format
Commits
57dc363b
Commit
57dc363b
authored
Sep 05, 2018
by
Kevin Atkinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gx update and fix code to use new Cid type
parent
1b70c30f
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
23 additions
and
23 deletions
+23
-23
batch_test.go
batch_test.go
+4
-4
daghelpers.go
daghelpers.go
+5
-5
daghelpers_test.go
daghelpers_test.go
+2
-2
format.go
format.go
+1
-1
format_test.go
format_test.go
+1
-1
merkledag.go
merkledag.go
+6
-6
package.json
package.json
+4
-4
No files found.
batch_test.go
View file @
57dc363b
...
...
@@ -18,7 +18,7 @@ func newTestDag() *testDag {
return
&
testDag
{
nodes
:
make
(
map
[
string
]
Node
)}
}
func
(
d
*
testDag
)
Get
(
ctx
context
.
Context
,
cid
*
cid
.
Cid
)
(
Node
,
error
)
{
func
(
d
*
testDag
)
Get
(
ctx
context
.
Context
,
cid
cid
.
Cid
)
(
Node
,
error
)
{
d
.
mu
.
Lock
()
defer
d
.
mu
.
Unlock
()
if
n
,
ok
:=
d
.
nodes
[
cid
.
KeyString
()];
ok
{
...
...
@@ -27,7 +27,7 @@ func (d *testDag) Get(ctx context.Context, cid *cid.Cid) (Node, error) {
return
nil
,
ErrNotFound
}
func
(
d
*
testDag
)
GetMany
(
ctx
context
.
Context
,
cids
[]
*
cid
.
Cid
)
<-
chan
*
NodeOption
{
func
(
d
*
testDag
)
GetMany
(
ctx
context
.
Context
,
cids
[]
cid
.
Cid
)
<-
chan
*
NodeOption
{
d
.
mu
.
Lock
()
defer
d
.
mu
.
Unlock
()
out
:=
make
(
chan
*
NodeOption
,
len
(
cids
))
...
...
@@ -58,14 +58,14 @@ func (d *testDag) AddMany(ctx context.Context, nodes []Node) error {
return
nil
}
func
(
d
*
testDag
)
Remove
(
ctx
context
.
Context
,
c
*
cid
.
Cid
)
error
{
func
(
d
*
testDag
)
Remove
(
ctx
context
.
Context
,
c
cid
.
Cid
)
error
{
d
.
mu
.
Lock
()
defer
d
.
mu
.
Unlock
()
delete
(
d
.
nodes
,
c
.
KeyString
())
return
nil
}
func
(
d
*
testDag
)
RemoveMany
(
ctx
context
.
Context
,
cids
[]
*
cid
.
Cid
)
error
{
func
(
d
*
testDag
)
RemoveMany
(
ctx
context
.
Context
,
cids
[]
cid
.
Cid
)
error
{
d
.
mu
.
Lock
()
defer
d
.
mu
.
Unlock
()
for
_
,
c
:=
range
cids
{
...
...
daghelpers.go
View file @
57dc363b
...
...
@@ -9,7 +9,7 @@ import (
// GetLinks returns the CIDs of the children of the given node. Prefer this
// method over looking up the node itself and calling `Links()` on it as this
// method may be able to use a link cache.
func
GetLinks
(
ctx
context
.
Context
,
ng
NodeGetter
,
c
*
cid
.
Cid
)
([]
*
Link
,
error
)
{
func
GetLinks
(
ctx
context
.
Context
,
ng
NodeGetter
,
c
cid
.
Cid
)
([]
*
Link
,
error
)
{
if
c
.
Type
()
==
cid
.
Raw
{
return
nil
,
nil
}
...
...
@@ -27,7 +27,7 @@ func GetLinks(ctx context.Context, ng NodeGetter, c *cid.Cid) ([]*Link, error) {
// It returns an array of NodePromise with the linked nodes all in the proper
// order.
func
GetDAG
(
ctx
context
.
Context
,
ds
NodeGetter
,
root
Node
)
[]
*
NodePromise
{
var
cids
[]
*
cid
.
Cid
var
cids
[]
cid
.
Cid
for
_
,
lnk
:=
range
root
.
Links
()
{
cids
=
append
(
cids
,
lnk
.
Cid
)
}
...
...
@@ -37,7 +37,7 @@ func GetDAG(ctx context.Context, ds NodeGetter, root Node) []*NodePromise {
// GetNodes returns an array of 'FutureNode' promises, with each corresponding
// to the key with the same index as the passed in keys
func
GetNodes
(
ctx
context
.
Context
,
ds
NodeGetter
,
keys
[]
*
cid
.
Cid
)
[]
*
NodePromise
{
func
GetNodes
(
ctx
context
.
Context
,
ds
NodeGetter
,
keys
[]
cid
.
Cid
)
[]
*
NodePromise
{
// Early out if no work to do
if
len
(
keys
)
==
0
{
...
...
@@ -89,7 +89,7 @@ func GetNodes(ctx context.Context, ds NodeGetter, keys []*cid.Cid) []*NodePromis
return
promises
}
func
Copy
(
ctx
context
.
Context
,
from
,
to
DAGService
,
root
*
cid
.
Cid
)
error
{
func
Copy
(
ctx
context
.
Context
,
from
,
to
DAGService
,
root
cid
.
Cid
)
error
{
node
,
err
:=
from
.
Get
(
ctx
,
root
)
if
err
!=
nil
{
return
err
...
...
@@ -109,7 +109,7 @@ func Copy(ctx context.Context, from, to DAGService, root *cid.Cid) error {
}
// Remove duplicates from a list of keys
func
dedupeKeys
(
cids
[]
*
cid
.
Cid
)
[]
*
cid
.
Cid
{
func
dedupeKeys
(
cids
[]
cid
.
Cid
)
[]
cid
.
Cid
{
set
:=
cid
.
NewSet
()
for
_
,
c
:=
range
cids
{
set
.
Add
(
c
)
...
...
daghelpers_test.go
View file @
57dc363b
...
...
@@ -43,10 +43,10 @@ func (n *TestNode) Copy() Node {
return
&
EmptyNode
{}
}
func
(
n
*
TestNode
)
Cid
()
*
cid
.
Cid
{
func
(
n
*
TestNode
)
Cid
()
cid
.
Cid
{
c
,
err
:=
n
.
builder
.
Sum
(
n
.
RawData
())
if
err
!=
nil
{
return
nil
return
cid
.
Cid
{}
}
return
c
}
...
...
format.go
View file @
57dc363b
...
...
@@ -53,7 +53,7 @@ type Link struct {
Size
uint64
// multihash of the target object
Cid
*
cid
.
Cid
Cid
cid
.
Cid
}
// NodeStat is a statistics object for a Node. Mostly sizes.
...
...
format_test.go
View file @
57dc363b
...
...
@@ -28,7 +28,7 @@ func (n *EmptyNode) Copy() Node {
return
&
EmptyNode
{}
}
func
(
n
*
EmptyNode
)
Cid
()
*
cid
.
Cid
{
func
(
n
*
EmptyNode
)
Cid
()
cid
.
Cid
{
id
,
err
:=
cid
.
Prefix
{
Version
:
1
,
Codec
:
cid
.
Raw
,
...
...
merkledag.go
View file @
57dc363b
...
...
@@ -20,10 +20,10 @@ type NodeGetter interface {
// Get retrieves nodes by CID. Depending on the NodeGetter
// implementation, this may involve fetching the Node from a remote
// machine; consider setting a deadline in the context.
Get
(
context
.
Context
,
*
cid
.
Cid
)
(
Node
,
error
)
Get
(
context
.
Context
,
cid
.
Cid
)
(
Node
,
error
)
// GetMany returns a channel of NodeOptions given a set of CIDs.
GetMany
(
context
.
Context
,
[]
*
cid
.
Cid
)
<-
chan
*
NodeOption
GetMany
(
context
.
Context
,
[]
cid
.
Cid
)
<-
chan
*
NodeOption
}
// NodeGetters can optionally implement this interface to make finding linked
...
...
@@ -31,11 +31,11 @@ type NodeGetter interface {
type
LinkGetter
interface
{
NodeGetter
// TODO(ipfs/go-ipld-format#9): This should return []
*
cid.Cid
// TODO(ipfs/go-ipld-format#9): This should return []cid.Cid
// GetLinks returns the children of the node refered to by the given
// CID.
GetLinks
(
ctx
context
.
Context
,
nd
*
cid
.
Cid
)
([]
*
Link
,
error
)
GetLinks
(
ctx
context
.
Context
,
nd
cid
.
Cid
)
([]
*
Link
,
error
)
}
// DAGService is an IPFS Merkle DAG service.
...
...
@@ -48,7 +48,7 @@ type DAGService interface {
// Remove removes a node from this DAG.
//
// Remove returns no error if the requested node is not present in this DAG.
Remove
(
context
.
Context
,
*
cid
.
Cid
)
error
Remove
(
context
.
Context
,
cid
.
Cid
)
error
// AddMany adds many nodes to this DAG.
//
...
...
@@ -59,5 +59,5 @@ type DAGService interface {
// RemoveMany removes many nodes from this DAG.
//
// It returns success even if the nodes were not present in the DAG.
RemoveMany
(
context
.
Context
,
[]
*
cid
.
Cid
)
error
RemoveMany
(
context
.
Context
,
[]
cid
.
Cid
)
error
}
package.json
View file @
57dc363b
...
...
@@ -9,15 +9,15 @@
"gxDependencies"
:
[
{
"author"
:
"whyrusleeping"
,
"hash"
:
"Qm
ZFbDTY9jfSBms2MchvYM9oYRbAF19K7Pby47yDBfpPrb
"
,
"hash"
:
"Qm
PSQnBKM9g7BaUcZCvswUJVscQ1ipjmwxN5PXCjkp9EQ7
"
,
"name"
:
"go-cid"
,
"version"
:
"0.
8
.0"
"version"
:
"0.
9
.0"
},
{
"author"
:
"stebalien"
,
"hash"
:
"Qm
WAzSEoqZ6xU6pu8yL8e5WaMb7wtbfbhhN4p1DknUPtr3
"
,
"hash"
:
"Qm
RcHuYzAyswytBuMF78rj3LTChYszomRFXNg4685ZN1WM
"
,
"name"
:
"go-block-format"
,
"version"
:
"0.
1.11
"
"version"
:
"0.
2.0
"
},
{
"author"
:
"multiformats"
,
...
...
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