rename import of go-ipld-format from node/format to ipld
License: MIT Signed-off-by: Steven Allen <steven@stebalien.com>
Steven Allen committed
Jan 29, 2018 at 11:55 UTC
f9d935b9841ec061e8e10fb9c3aac5b7917720cd
66 files changed
+405
-405
core/commands/dag/dag.go
+2
-2
@@ -18,7 +18,7 @@ import (
18
cid "gx/ipfs/QmcZfnkapfECQGcLZaf9B79NRg7cRa9EnZh4LSbkCzwNvY/go-cid"
19
cmdkit "gx/ipfs/QmceUdzxkimdYsgtX733uNgzf1DLHyBKN6ehGSp85ayppM/go-ipfs-cmdkit"
20
files "gx/ipfs/QmceUdzxkimdYsgtX733uNgzf1DLHyBKN6ehGSp85ayppM/go-ipfs-cmdkit/files"
21
- node "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
21
+ ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
22
)
23
24
var log = logging.Logger("cmds/files")
@@ -103,7 +103,7 @@ into an object of the specified format.
103
104
addAllAndPin := func(f files.File) error {
105
cids := cid.NewSet()
106
- b := node.NewBatch(req.Context(), n.DAG)
106
+ b := ipld.NewBatch(req.Context(), n.DAG)
107
108
for {
109
file, err := f.NextFile()
core/commands/dht.go
+2
-2
@@ -20,7 +20,7 @@ import (
20
cid "gx/ipfs/QmcZfnkapfECQGcLZaf9B79NRg7cRa9EnZh4LSbkCzwNvY/go-cid"
21
"gx/ipfs/QmceUdzxkimdYsgtX733uNgzf1DLHyBKN6ehGSp85ayppM/go-ipfs-cmdkit"
22
ipdht "gx/ipfs/Qmdm5sm2xHCXNaWdxpjhFeStvSNMRhKQkqpBX7aDcqXtfT/go-libp2p-kad-dht"
23
- node "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
23
+ ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
24
pstore "gx/ipfs/QmeZVQzUrXqaszo24DAoHfGzcmCptN9JyngLkGAiEfk2x7/go-libp2p-peerstore"
25
)
26
@@ -378,7 +378,7 @@ func provideKeys(ctx context.Context, r routing.IpfsRouting, cids []*cid.Cid) er
378
return nil
379
}
380
381
-func provideKeysRec(ctx context.Context, r routing.IpfsRouting, dserv node.DAGService, cids []*cid.Cid) error {
381
+func provideKeysRec(ctx context.Context, r routing.IpfsRouting, dserv ipld.DAGService, cids []*cid.Cid) error {
382
provided := cid.NewSet()
383
for _, c := range cids {
384
kset := cid.NewSet()
core/commands/files/files.go
+3
-3
@@ -23,7 +23,7 @@ import (
23
mh "gx/ipfs/QmZyZDi491cCNTLfAhwcaDii2Kg4pwKRkhqQzURGDvY6ua/go-multihash"
24
cid "gx/ipfs/QmcZfnkapfECQGcLZaf9B79NRg7cRa9EnZh4LSbkCzwNvY/go-cid"
25
cmdkit "gx/ipfs/QmceUdzxkimdYsgtX733uNgzf1DLHyBKN6ehGSp85ayppM/go-ipfs-cmdkit"
26
- node "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
26
+ ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
27
)
28
29
var log = logging.Logger("cmds/files")
@@ -170,7 +170,7 @@ func statGetFormatOptions(req cmds.Request) (string, error) {
170
}
171
}
172
173
-func statNode(ds node.DAGService, fsn mfs.FSNode) (*Object, error) {
173
+func statNode(ds ipld.DAGService, fsn mfs.FSNode) (*Object, error) {
174
nd, err := fsn.GetNode()
175
if err != nil {
176
return nil, err
@@ -278,7 +278,7 @@ var FilesCpCmd = &cmds.Command{
278
},
279
}
280
281
-func getNodeFromPath(ctx context.Context, node *core.IpfsNode, p string) (node.Node, error) {
281
+func getNodeFromPath(ctx context.Context, node *core.IpfsNode, p string) (ipld.Node, error) {
282
switch {
283
case strings.HasPrefix(p, "/ipfs/"):
284
np, err := path.ParsePath(p)
core/commands/ls.go
+4
-4
@@ -18,7 +18,7 @@ import (
18
unixfspb "github.com/ipfs/go-ipfs/unixfs/pb"
19
20
"gx/ipfs/QmceUdzxkimdYsgtX733uNgzf1DLHyBKN6ehGSp85ayppM/go-ipfs-cmdkit"
21
- node "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
21
+ ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
22
)
23
24
type LsLink struct {
@@ -84,7 +84,7 @@ The JSON output contains type information.
84
85
paths := req.Arguments()
86
87
- var dagnodes []node.Node
87
+ var dagnodes []ipld.Node
88
for _, fpath := range paths {
89
p, err := path.ParsePath(fpath)
90
if err != nil {
@@ -114,7 +114,7 @@ The JSON output contains type information.
114
return
115
}
116
117
- var links []*node.Link
117
+ var links []*ipld.Link
118
if dir == nil {
119
links = dagnode.Links()
120
} else {
@@ -134,7 +134,7 @@ The JSON output contains type information.
134
t := unixfspb.Data_DataType(-1)
135
136
linkNode, err := link.GetNode(req.Context(), dserv)
137
- if err == node.ErrNotFound && !resolve {
137
+ if err == ipld.ErrNotFound && !resolve {
138
// not an error
139
linkNode = nil
140
} else if err != nil {
core/commands/object/object.go
+6
-6
@@ -23,7 +23,7 @@ import (
23
24
cid "gx/ipfs/QmcZfnkapfECQGcLZaf9B79NRg7cRa9EnZh4LSbkCzwNvY/go-cid"
25
cmdkit "gx/ipfs/QmceUdzxkimdYsgtX733uNgzf1DLHyBKN6ehGSp85ayppM/go-ipfs-cmdkit"
26
- node "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
26
+ ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
27
)
28
29
// ErrObjectTooLarge is returned when too much data was read from stdin. current limit 2m
@@ -313,7 +313,7 @@ var ObjectStatCmd = &cmds.Command{
313
314
res.SetOutput(ns)
315
},
316
- Type: node.NodeStat{},
316
+ Type: ipld.NodeStat{},
317
Marshalers: cmds.MarshalerMap{
318
cmds.Text: func(res cmds.Response) (io.Reader, error) {
319
v, err := unwrapOutput(res.Output())
@@ -321,7 +321,7 @@ var ObjectStatCmd = &cmds.Command{
321
return nil, err
322
}
323
324
- ns, ok := v.(*node.NodeStat)
324
+ ns, ok := v.(*ipld.NodeStat)
325
if !ok {
326
return nil, e.TypeErr(ns, v)
327
}
@@ -632,7 +632,7 @@ func getObjectEnc(o interface{}) objectEncoding {
632
return objectEncoding(v)
633
}
634
635
-func getOutput(dagnode node.Node) (*Object, error) {
635
+func getOutput(dagnode ipld.Node) (*Object, error) {
636
c := dagnode.Cid()
637
output := &Object{
638
Hash: c.String(),
@@ -663,13 +663,13 @@ func deserializeNode(nd *Node, dataFieldEncoding string) (*dag.ProtoNode, error)
663
return nil, fmt.Errorf("Unkown data field encoding")
664
}
665
666
- dagnode.SetLinks(make([]*node.Link, len(nd.Links)))
666
+ dagnode.SetLinks(make([]*ipld.Link, len(nd.Links)))
667
for i, link := range nd.Links {
668
c, err := cid.Decode(link.Hash)
669
if err != nil {
670
return nil, err
671
}
672
- dagnode.Links()[i] = &node.Link{
672
+ dagnode.Links()[i] = &ipld.Link{
673
Name: link.Name,
674
Size: link.Size,
675
Cid: c,
core/commands/refs.go
+8
-8
@@ -14,7 +14,7 @@ import (
14
15
cid "gx/ipfs/QmcZfnkapfECQGcLZaf9B79NRg7cRa9EnZh4LSbkCzwNvY/go-cid"
16
"gx/ipfs/QmceUdzxkimdYsgtX733uNgzf1DLHyBKN6ehGSp85ayppM/go-ipfs-cmdkit"
17
- node "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
17
+ ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
18
)
19
20
// KeyList is a general type for outputting lists of keys
@@ -197,8 +197,8 @@ var refsMarshallerMap = cmds.MarshalerMap{
197
},
198
}
199
200
-func objectsForPaths(ctx context.Context, n *core.IpfsNode, paths []string) ([]node.Node, error) {
201
- objects := make([]node.Node, len(paths))
200
+func objectsForPaths(ctx context.Context, n *core.IpfsNode, paths []string) ([]ipld.Node, error) {
201
+ objects := make([]ipld.Node, len(paths))
202
for i, sp := range paths {
203
p, err := path.ParsePath(sp)
204
if err != nil {
@@ -221,7 +221,7 @@ type RefWrapper struct {
221
222
type RefWriter struct {
223
out chan interface{}
224
- DAG node.DAGService
224
+ DAG ipld.DAGService
225
Ctx context.Context
226
227
Unique bool
@@ -232,18 +232,18 @@ type RefWriter struct {
232
}
233
234
// WriteRefs writes refs of the given object to the underlying writer.
235
-func (rw *RefWriter) WriteRefs(n node.Node) (int, error) {
235
+func (rw *RefWriter) WriteRefs(n ipld.Node) (int, error) {
236
if rw.Recursive {
237
return rw.writeRefsRecursive(n)
238
}
239
return rw.writeRefsSingle(n)
240
}
241
242
-func (rw *RefWriter) writeRefsRecursive(n node.Node) (int, error) {
242
+func (rw *RefWriter) writeRefsRecursive(n ipld.Node) (int, error) {
243
nc := n.Cid()
244
245
var count int
246
- for i, ng := range node.GetDAG(rw.Ctx, rw.DAG, n) {
246
+ for i, ng := range ipld.GetDAG(rw.Ctx, rw.DAG, n) {
247
lc := n.Links()[i].Cid
248
if rw.skip(lc) {
249
continue
@@ -267,7 +267,7 @@ func (rw *RefWriter) writeRefsRecursive(n node.Node) (int, error) {
267
return count, nil
268
}
269
270
-func (rw *RefWriter) writeRefsSingle(n node.Node) (int, error) {
270
+func (rw *RefWriter) writeRefsSingle(n ipld.Node) (int, error) {
271
c := n.Cid()
272
273
if rw.skip(c) {
core/core.go
+2
-2
@@ -70,7 +70,7 @@ import (
70
metrics "gx/ipfs/Qmb1QrSXKwGFWgiGEcyac4s5wakJG4yPvCPk49xZHxr5ux/go-libp2p-metrics"
71
cid "gx/ipfs/QmcZfnkapfECQGcLZaf9B79NRg7cRa9EnZh4LSbkCzwNvY/go-cid"
72
dht "gx/ipfs/Qmdm5sm2xHCXNaWdxpjhFeStvSNMRhKQkqpBX7aDcqXtfT/go-libp2p-kad-dht"
73
- node "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
73
+ ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
74
pstore "gx/ipfs/QmeZVQzUrXqaszo24DAoHfGzcmCptN9JyngLkGAiEfk2x7/go-libp2p-peerstore"
75
circuit "gx/ipfs/Qmet8Dv4K3w6aGjNfX5MCRmu1KzJtkKhw1sCzQm2bvGNwP/go-libp2p-circuit"
76
mafilter "gx/ipfs/Qmf2UAmRwDG4TvnkQpHZWPAzw7rpCYVhxmRXmYxXr5LD1g/go-maddr-filter"
@@ -118,7 +118,7 @@ type IpfsNode struct {
118
BaseBlocks bstore.Blockstore // the raw blockstore, no filestore wrapping
119
GCLocker bstore.GCLocker // the locker used to protect the blockstore during gc
120
Blocks bserv.BlockService // the block service, get/add blocks.
121
- DAG node.DAGService // the merkle dag service, get/add objects.
121
+ DAG ipld.DAGService // the merkle dag service, get/add objects.
122
Resolver *path.Resolver // the path resolution system
123
Reporter metrics.Reporter
124
Discovery discovery.Service
core/coreapi/unixfs.go
+2
-2
@@ -9,7 +9,7 @@ import (
9
uio "github.com/ipfs/go-ipfs/unixfs/io"
10
11
cid "gx/ipfs/QmcZfnkapfECQGcLZaf9B79NRg7cRa9EnZh4LSbkCzwNvY/go-cid"
12
- node "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
12
+ ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
13
)
14
15
type UnixfsAPI CoreAPI
@@ -52,7 +52,7 @@ func (api *UnixfsAPI) Ls(ctx context.Context, p coreiface.Path) ([]*coreiface.Li
52
return nil, err
53
}
54
55
- var ndlinks []*node.Link
55
+ var ndlinks []*ipld.Link
56
dir, err := uio.NewDirectoryFromNode(api.node.DAG, dagnode)
57
switch err {
58
case nil:
core/coredag/cbor.go
+5
-5
@@ -5,19 +5,19 @@ import (
5
"io/ioutil"
6
7
ipldcbor "gx/ipfs/QmNRz7BDWfdFNVLt7AVvmRefkrURD25EeoipcXqo6yoXU1/go-ipld-cbor"
8
- node "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
8
+ ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
9
)
10
11
-func cborJSONParser(r io.Reader, mhType uint64, mhLen int) ([]node.Node, error) {
11
+func cborJSONParser(r io.Reader, mhType uint64, mhLen int) ([]ipld.Node, error) {
12
nd, err := ipldcbor.FromJson(r, mhType, mhLen)
13
if err != nil {
14
return nil, err
15
}
16
17
- return []node.Node{nd}, nil
17
+ return []ipld.Node{nd}, nil
18
}
19
20
-func cborRawParser(r io.Reader, mhType uint64, mhLen int) ([]node.Node, error) {
20
+func cborRawParser(r io.Reader, mhType uint64, mhLen int) ([]ipld.Node, error) {
21
data, err := ioutil.ReadAll(r)
22
if err != nil {
23
return nil, err
@@ -28,5 +28,5 @@ func cborRawParser(r io.Reader, mhType uint64, mhLen int) ([]node.Node, error) {
28
return nil, err
29
}
30
31
- return []node.Node{nd}, nil
31
+ return []ipld.Node{nd}, nil
32
}
core/coredag/dagpb.go
+5
-5
@@ -9,10 +9,10 @@ import (
9
10
mh "gx/ipfs/QmZyZDi491cCNTLfAhwcaDii2Kg4pwKRkhqQzURGDvY6ua/go-multihash"
11
cid "gx/ipfs/QmcZfnkapfECQGcLZaf9B79NRg7cRa9EnZh4LSbkCzwNvY/go-cid"
12
- node "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
12
+ ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
13
)
14
15
-func dagpbJSONParser(r io.Reader, mhType uint64, mhLen int) ([]node.Node, error) {
15
+func dagpbJSONParser(r io.Reader, mhType uint64, mhLen int) ([]ipld.Node, error) {
16
data, err := ioutil.ReadAll(r)
17
if err != nil {
18
return nil, err
@@ -27,10 +27,10 @@ func dagpbJSONParser(r io.Reader, mhType uint64, mhLen int) ([]node.Node, error)
27
28
nd.SetPrefix(cidPrefix(mhType, mhLen))
29
30
- return []node.Node{nd}, nil
30
+ return []ipld.Node{nd}, nil
31
}
32
33
-func dagpbRawParser(r io.Reader, mhType uint64, mhLen int) ([]node.Node, error) {
33
+func dagpbRawParser(r io.Reader, mhType uint64, mhLen int) ([]ipld.Node, error) {
34
data, err := ioutil.ReadAll(r)
35
if err != nil {
36
return nil, err
@@ -43,7 +43,7 @@ func dagpbRawParser(r io.Reader, mhType uint64, mhLen int) ([]node.Node, error)
43
44
nd.SetPrefix(cidPrefix(mhType, mhLen))
45
46
- return []node.Node{nd}, nil
46
+ return []ipld.Node{nd}, nil
47
}
48
49
func cidPrefix(mhType uint64, mhLen int) *cid.Prefix {
core/coredag/dagtransl.go
+4
-4
@@ -4,11 +4,11 @@ import (
4
"fmt"
5
"io"
6
7
- node "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
7
+ ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
8
)
9
10
// DagParser is function used for parsing stream into Node
11
-type DagParser func(r io.Reader, mhType uint64, mhLen int) ([]node.Node, error)
11
+type DagParser func(r io.Reader, mhType uint64, mhLen int) ([]ipld.Node, error)
12
13
// FormatParsers is used for mapping format descriptors to DagParsers
14
type FormatParsers map[string]DagParser
@@ -48,7 +48,7 @@ var defaultCborParsers = FormatParsers{
48
49
// ParseInputs uses DefaultInputEncParsers to parse io.Reader described by
50
// input encoding and format to an instance of ipld Node
51
-func ParseInputs(ienc, format string, r io.Reader, mhType uint64, mhLen int) ([]node.Node, error) {
51
+func ParseInputs(ienc, format string, r io.Reader, mhType uint64, mhLen int) ([]ipld.Node, error) {
52
return DefaultInputEncParsers.ParseInputs(ienc, format, r, mhType, mhLen)
53
}
54
@@ -65,7 +65,7 @@ func (iep InputEncParsers) AddParser(ienv, format string, f DagParser) {
65
66
// ParseInputs parses io.Reader described by input encoding and format to
67
// an instance of ipld Node
68
-func (iep InputEncParsers) ParseInputs(ienc, format string, r io.Reader, mhType uint64, mhLen int) ([]node.Node, error) {
68
+func (iep InputEncParsers) ParseInputs(ienc, format string, r io.Reader, mhType uint64, mhLen int) ([]ipld.Node, error) {
69
parsers, ok := iep[ienc]
70
if !ok {
71
return nil, fmt.Errorf("no input parser for %q", ienc)
core/coredag/raw.go
+3
-3
@@ -9,11 +9,11 @@ import (
9
10
mh "gx/ipfs/QmZyZDi491cCNTLfAhwcaDii2Kg4pwKRkhqQzURGDvY6ua/go-multihash"
11
cid "gx/ipfs/QmcZfnkapfECQGcLZaf9B79NRg7cRa9EnZh4LSbkCzwNvY/go-cid"
12
- node "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
12
+ ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
13
block "gx/ipfs/Qmej7nf81hi2x2tvjRBF3mcp74sQyuDH4VMYDGd1YtXjb2/go-block-format"
14
)
15
16
-func rawRawParser(r io.Reader, mhType uint64, mhLen int) ([]node.Node, error) {
16
+func rawRawParser(r io.Reader, mhType uint64, mhLen int) ([]ipld.Node, error) {
17
if mhType == math.MaxUint64 {
18
mhType = mh.SHA2_256
19
}
@@ -33,5 +33,5 @@ func rawRawParser(r io.Reader, mhType uint64, mhLen int) ([]node.Node, error) {
33
return nil, err
34
}
35
nd := &merkledag.RawNode{Block: blk}
36
- return []node.Node{nd}, nil
36
+ return []ipld.Node{nd}, nil
37
}
core/corehttp/gateway_handler.go
+4
-4
@@ -26,7 +26,7 @@ import (
26
humanize "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize"
27
routing "gx/ipfs/QmRijoA6zGS98ELTDbGsLWPZbVotYsGbjp3RbXcKCYBeon/go-libp2p-routing"
28
cid "gx/ipfs/QmcZfnkapfECQGcLZaf9B79NRg7cRa9EnZh4LSbkCzwNvY/go-cid"
29
- node "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
29
+ ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
30
multibase "gx/ipfs/QmexBtiTTEwwn42Yi6ouKt6VqzpA6wjJgiW1oh9VfaRrup/go-multibase"
31
)
32
@@ -53,7 +53,7 @@ func newGatewayHandler(n *core.IpfsNode, c GatewayConfig, api coreiface.CoreAPI)
53
}
54
55
// TODO(cryptix): find these helpers somewhere else
56
-func (i *gatewayHandler) newDagFromReader(r io.Reader) (node.Node, error) {
56
+func (i *gatewayHandler) newDagFromReader(r io.Reader) (ipld.Node, error) {
57
// TODO(cryptix): change and remove this helper once PR1136 is merged
58
// return ufs.AddFromReader(i.node, r.Body)
59
return importer.BuildDagFromReader(
@@ -316,7 +316,7 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr
316
317
// storage for directory listing
318
var dirListing []directoryItem
319
- dirr.ForEachLink(ctx, func(link *node.Link) error {
319
+ dirr.ForEachLink(ctx, func(link *ipld.Link) error {
320
// See comment above where originalUrlPath is declared.
321
di := directoryItem{humanize.Bytes(link.Size), link.Name, gopath.Join(originalUrlPath, link.Name)}
322
dirListing = append(dirListing, di)
@@ -425,7 +425,7 @@ func (i *gatewayHandler) putHandler(w http.ResponseWriter, r *http.Request) {
425
return
426
}
427
428
- var newnode node.Node
428
+ var newnode ipld.Node
429
if rsegs[len(rsegs)-1] == "QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn" {
430
newnode = ft.EmptyDirNode()
431
} else {
core/coreunix/add.go
+12
-12
@@ -29,7 +29,7 @@ import (
29
logging "gx/ipfs/QmSpJByNKFX1sCsHBEp3R73FL4NF6FnQTEGyNAXHm2GS52/go-log"
30
cid "gx/ipfs/QmcZfnkapfECQGcLZaf9B79NRg7cRa9EnZh4LSbkCzwNvY/go-cid"
31
files "gx/ipfs/QmceUdzxkimdYsgtX733uNgzf1DLHyBKN6ehGSp85ayppM/go-ipfs-cmdkit/files"
32
- node "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
32
+ ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
33
)
34
35
var log = logging.Logger("coreunix")
@@ -74,7 +74,7 @@ type AddedObject struct {
74
}
75
76
// NewAdder Returns a new Adder used for a file add operation.
77
-func NewAdder(ctx context.Context, p pin.Pinner, bs bstore.GCBlockstore, ds node.DAGService) (*Adder, error) {
77
+func NewAdder(ctx context.Context, p pin.Pinner, bs bstore.GCBlockstore, ds ipld.DAGService) (*Adder, error) {
78
return &Adder{
79
ctx: ctx,
80
pinning: p,
@@ -94,7 +94,7 @@ type Adder struct {
94
ctx context.Context
95
pinning pin.Pinner
96
blockstore bstore.GCBlockstore
97
- dagService node.DAGService
97
+ dagService ipld.DAGService
98
Out chan interface{}
99
Progress bool
100
Hidden bool
@@ -105,7 +105,7 @@ type Adder struct {
105
Wrap bool
106
NoCopy bool
107
Chunker string
108
- root node.Node
108
+ root ipld.Node
109
mroot *mfs.Root
110
unlocker bs.Unlocker
111
tempRoot *cid.Cid
@@ -133,7 +133,7 @@ func (adder *Adder) SetMfsRoot(r *mfs.Root) {
133
}
134
135
// Constructs a node from reader's data, and adds it. Doesn't pin.
136
-func (adder *Adder) add(reader io.Reader) (node.Node, error) {
136
+func (adder *Adder) add(reader io.Reader) (ipld.Node, error) {
137
chnk, err := chunk.FromString(reader, adder.Chunker)
138
if err != nil {
139
return nil, err
@@ -155,7 +155,7 @@ func (adder *Adder) add(reader io.Reader) (node.Node, error) {
155
}
156
157
// RootNode returns the root node of the Added.
158
-func (adder *Adder) RootNode() (node.Node, error) {
158
+func (adder *Adder) RootNode() (ipld.Node, error) {
159
// for memoizing
160
if adder.root != nil {
161
return adder.root, nil
@@ -215,7 +215,7 @@ func (adder *Adder) PinRoot() error {
215
}
216
217
// Finalize flushes the mfs root directory and returns the mfs root node.
218
-func (adder *Adder) Finalize() (node.Node, error) {
218
+func (adder *Adder) Finalize() (ipld.Node, error) {
219
mr, err := adder.mfsRoot()
220
if err != nil {
221
return nil, err
@@ -365,7 +365,7 @@ func AddR(n *core.IpfsNode, root string) (key string, err error) {
365
// to preserve the filename.
366
// Returns the path of the added file ("<dir hash>/filename"), the DAG node of
367
// the directory, and and error if any.
368
-func AddWrapped(n *core.IpfsNode, r io.Reader, filename string) (string, node.Node, error) {
368
+func AddWrapped(n *core.IpfsNode, r io.Reader, filename string) (string, ipld.Node, error) {
369
file := files.NewReaderFile(filename, filename, ioutil.NopCloser(r), nil)
370
fileAdder, err := NewAdder(n.Context(), n.Pinning, n.Blockstore, n.DAG)
371
if err != nil {
@@ -389,7 +389,7 @@ func AddWrapped(n *core.IpfsNode, r io.Reader, filename string) (string, node.No
389
return gopath.Join(c.String(), filename), dagnode, nil
390
}
391
392
-func (adder *Adder) addNode(node node.Node, path string) error {
392
+func (adder *Adder) addNode(node ipld.Node, path string) error {
393
// patch it into the root
394
if path == "" {
395
path = node.Cid().String()
@@ -555,7 +555,7 @@ func (adder *Adder) maybePauseForGC() error {
555
}
556
557
// outputDagnode sends dagnode info over the output channel
558
-func outputDagnode(out chan interface{}, name string, dn node.Node) error {
558
+func outputDagnode(out chan interface{}, name string, dn ipld.Node) error {
559
if out == nil {
560
return nil
561
}
@@ -575,7 +575,7 @@ func outputDagnode(out chan interface{}, name string, dn node.Node) error {
575
}
576
577
// NewMemoryDagService builds and returns a new mem-datastore.
578
-func NewMemoryDagService() node.DAGService {
578
+func NewMemoryDagService() ipld.DAGService {
579
// build mem-datastore for editor's intermediary nodes
580
bs := bstore.NewBlockstore(syncds.MutexWrap(ds.NewMapDatastore()))
581
bsrv := bserv.New(bs, offline.Exchange(bs))
@@ -583,7 +583,7 @@ func NewMemoryDagService() node.DAGService {
583
}
584
585
// from core/commands/object.go
586
-func getOutput(dagnode node.Node) (*Object, error) {
586
+func getOutput(dagnode ipld.Node) (*Object, error) {
587
c := dagnode.Cid()
588
s, err := dagnode.Size()
589
if err != nil {
core/coreunix/metadata_test.go
+2
-2
@@ -20,10 +20,10 @@ import (
20
ds "gx/ipfs/QmPpegoMqhAEqjncrzArm7KVWAkCm78rqL2DPuNjhPrshg/go-datastore"
21
dssync "gx/ipfs/QmPpegoMqhAEqjncrzArm7KVWAkCm78rqL2DPuNjhPrshg/go-datastore/sync"
22
cid "gx/ipfs/QmcZfnkapfECQGcLZaf9B79NRg7cRa9EnZh4LSbkCzwNvY/go-cid"
23
- node "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
23
+ ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
24
)
25
26
-func getDagserv(t *testing.T) node.DAGService {
26
+func getDagserv(t *testing.T) ipld.DAGService {
27
db := dssync.MutexWrap(ds.NewMapDatastore())
28
bs := bstore.NewBlockstore(db)
29
blockserv := bserv.New(bs, offline.Exchange(bs))
core/pathresolver.go
+2
-2
@@ -10,7 +10,7 @@ import (
10
11
logging "gx/ipfs/QmSpJByNKFX1sCsHBEp3R73FL4NF6FnQTEGyNAXHm2GS52/go-log"
12
cid "gx/ipfs/QmcZfnkapfECQGcLZaf9B79NRg7cRa9EnZh4LSbkCzwNvY/go-cid"
13
- node "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
13
+ ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
14
)
15
16
// ErrNoNamesys is an explicit error for when an IPFS node doesn't
@@ -21,7 +21,7 @@ var ErrNoNamesys = errors.New(
21
// Resolve resolves the given path by parsing out protocol-specific
22
// entries (e.g. /ipns/<node-key>) and then going through the /ipfs/
23
// entries and returning the final node.
24
-func Resolve(ctx context.Context, nsys namesys.NameSystem, r *path.Resolver, p path.Path) (node.Node, error) {
24
+func Resolve(ctx context.Context, nsys namesys.NameSystem, r *path.Resolver, p path.Path) (ipld.Node, error) {
25
if strings.HasPrefix(p.String(), "/ipns/") {
26
evt := log.EventBegin(ctx, "resolveIpnsPath")
27
defer evt.Done()
exchange/reprovide/providers.go
+3
-3
@@ -6,7 +6,7 @@ import (
6
blocks "github.com/ipfs/go-ipfs/blocks/blockstore"
7
merkledag "github.com/ipfs/go-ipfs/merkledag"
8
pin "github.com/ipfs/go-ipfs/pin"
9
- node "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
9
+ ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
10
11
cid "gx/ipfs/QmcZfnkapfECQGcLZaf9B79NRg7cRa9EnZh4LSbkCzwNvY/go-cid"
12
)
@@ -19,7 +19,7 @@ func NewBlockstoreProvider(bstore blocks.Blockstore) KeyChanFunc {
19
}
20
21
// NewPinnedProvider returns provider supplying pinned keys
22
-func NewPinnedProvider(pinning pin.Pinner, dag node.DAGService, onlyRoots bool) KeyChanFunc {
22
+func NewPinnedProvider(pinning pin.Pinner, dag ipld.DAGService, onlyRoots bool) KeyChanFunc {
23
return func(ctx context.Context) (<-chan *cid.Cid, error) {
24
set, err := pinSet(ctx, pinning, dag, onlyRoots)
25
if err != nil {
@@ -43,7 +43,7 @@ func NewPinnedProvider(pinning pin.Pinner, dag node.DAGService, onlyRoots bool)
43
}
44
}
45
46
-func pinSet(ctx context.Context, pinning pin.Pinner, dag node.DAGService, onlyRoots bool) (*streamingSet, error) {
46
+func pinSet(ctx context.Context, pinning pin.Pinner, dag ipld.DAGService, onlyRoots bool) (*streamingSet, error) {
47
set := newStreamingSet()
48
49
go func() {
fuse/readonly/ipfs_test.go
+3
-3
@@ -24,7 +24,7 @@ import (
24
25
u "gx/ipfs/QmNiJuT8Ja3hMVpBHXv3Q6dwmperaQ6JjLtpMQgMCD7xvx/go-ipfs-util"
26
fstest "gx/ipfs/QmaFNtBAXX4nVMQWbUqNysXyhevUj1k4B1y5uS45LC7Vw9/fuse/fs/fstestutil"
27
- node "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
27
+ ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
28
)
29
30
func maybeSkipFuseTests(t *testing.T) {
@@ -33,7 +33,7 @@ func maybeSkipFuseTests(t *testing.T) {
33
}
34
}
35
36
-func randObj(t *testing.T, nd *core.IpfsNode, size int64) (node.Node, []byte) {
36
+func randObj(t *testing.T, nd *core.IpfsNode, size int64) (ipld.Node, []byte) {
37
buf := make([]byte, size)
38
u.NewTimeSeededRand().Read(buf)
39
read := bytes.NewReader(buf)
@@ -116,7 +116,7 @@ func TestIpfsStressRead(t *testing.T) {
116
nd, mnt := setupIpfsTest(t, nil)
117
defer mnt.Close()
118
119
- var nodes []node.Node
119
+ var nodes []ipld.Node
120
var paths []string
121
122
nobj := 50
fuse/readonly/readonly_unix.go
+4
-4
@@ -21,7 +21,7 @@ import (
21
proto "gx/ipfs/QmZ4Qi3GaRbjcx28Sme5eMH7RQjGkt8wHxt2a65oLaeFEV/gogo-protobuf/proto"
22
fuse "gx/ipfs/QmaFNtBAXX4nVMQWbUqNysXyhevUj1k4B1y5uS45LC7Vw9/fuse"
23
fs "gx/ipfs/QmaFNtBAXX4nVMQWbUqNysXyhevUj1k4B1y5uS45LC7Vw9/fuse/fs"
24
- node "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
24
+ ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
25
)
26
27
var log = logging.Logger("fuse/ipfs")
@@ -92,7 +92,7 @@ func (*Root) ReadDirAll(ctx context.Context) ([]fuse.Dirent, error) {
92
// Node is the core object representing a filesystem tree node.
93
type Node struct {
94
Ipfs *core.IpfsNode
95
- Nd node.Node
95
+ Nd ipld.Node
96
cached *ftpb.Data
97
}
98
@@ -157,7 +157,7 @@ func (s *Node) Lookup(ctx context.Context, name string) (fs.Node, error) {
157
158
nd, err := s.Ipfs.DAG.Get(ctx, link.Cid)
159
switch err {
160
- case node.ErrNotFound:
160
+ case ipld.ErrNotFound:
161
default:
162
log.Errorf("fuse lookup %q: %s", name, err)
163
return nil, err
@@ -177,7 +177,7 @@ func (s *Node) ReadDirAll(ctx context.Context) ([]fuse.Dirent, error) {
177
}
178
179
var entries []fuse.Dirent
180
- err = dir.ForEachLink(ctx, func(lnk *node.Link) error {
180
+ err = dir.ForEachLink(ctx, func(lnk *ipld.Link) error {
181
n := lnk.Name
182
if len(n) == 0 {
183
n = lnk.Cid.String()
importer/balanced/balanced_test.go
+3
-3
@@ -16,12 +16,12 @@ import (
16
uio "github.com/ipfs/go-ipfs/unixfs/io"
17
18
u "gx/ipfs/QmNiJuT8Ja3hMVpBHXv3Q6dwmperaQ6JjLtpMQgMCD7xvx/go-ipfs-util"
19
- node "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
19
+ ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
20
)
21
22
// TODO: extract these tests and more as a generic layout test suite
23
24
-func buildTestDag(ds node.DAGService, spl chunk.Splitter) (*dag.ProtoNode, error) {
24
+func buildTestDag(ds ipld.DAGService, spl chunk.Splitter) (*dag.ProtoNode, error) {
25
dbp := h.DagBuilderParams{
26
Dagserv: ds,
27
Maxlinks: h.DefaultLinksPerBlock,
@@ -35,7 +35,7 @@ func buildTestDag(ds node.DAGService, spl chunk.Splitter) (*dag.ProtoNode, error
35
return nd.(*dag.ProtoNode), nil
36
}
37
38
-func getTestDag(t *testing.T, ds node.DAGService, size int64, blksize int64) (*dag.ProtoNode, []byte) {
38
+func getTestDag(t *testing.T, ds ipld.DAGService, size int64, blksize int64) (*dag.ProtoNode, []byte) {
39
data := make([]byte, size)
40
u.NewTimeSeededRand().Read(data)
41
r := bytes.NewReader(data)
importer/balanced/builder.go
+2
-2
@@ -5,10 +5,10 @@ import (
5
6
h "github.com/ipfs/go-ipfs/importer/helpers"
7
8
- node "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
8
+ ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
9
)
10
11
-func BalancedLayout(db *h.DagBuilderHelper) (node.Node, error) {
11
+func BalancedLayout(db *h.DagBuilderHelper) (ipld.Node, error) {
12
var offset uint64 = 0
13
var root *h.UnixfsNode
14
for level := 0; !db.Done(); level++ {
importer/helpers/dagbuilder.go
+7
-7
@@ -11,19 +11,19 @@ import (
11
12
cid "gx/ipfs/QmcZfnkapfECQGcLZaf9B79NRg7cRa9EnZh4LSbkCzwNvY/go-cid"
13
files "gx/ipfs/QmceUdzxkimdYsgtX733uNgzf1DLHyBKN6ehGSp85ayppM/go-ipfs-cmdkit/files"
14
- node "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
14
+ ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
15
)
16
17
// DagBuilderHelper wraps together a bunch of objects needed to
18
// efficiently create unixfs dag trees
19
type DagBuilderHelper struct {
20
- dserv node.DAGService
20
+ dserv ipld.DAGService
21
spl chunk.Splitter
22
recvdErr error
23
rawLeaves bool
24
nextData []byte // the next item to return.
25
maxlinks int
26
- batch *node.Batch
26
+ batch *ipld.Batch
27
fullPath string
28
stat os.FileInfo
29
prefix *cid.Prefix
@@ -41,7 +41,7 @@ type DagBuilderParams struct {
41
Prefix *cid.Prefix
42
43
// DAGService to write blocks to (required)
44
- Dagserv node.DAGService
44
+ Dagserv ipld.DAGService
45
46
// NoCopy signals to the chunker that it should track fileinfo for
47
// filestore adds
@@ -57,7 +57,7 @@ func (dbp *DagBuilderParams) New(spl chunk.Splitter) *DagBuilderHelper {
57
rawLeaves: dbp.RawLeaves,
58
prefix: dbp.Prefix,
59
maxlinks: dbp.Maxlinks,
60
- batch: node.NewBatch(context.TODO(), dbp.Dagserv),
60
+ batch: ipld.NewBatch(context.TODO(), dbp.Dagserv),
61
}
62
if fi, ok := spl.Reader().(files.FileInfo); dbp.NoCopy && ok {
63
db.fullPath = fi.AbsPath()
@@ -107,7 +107,7 @@ func (db *DagBuilderHelper) Next() ([]byte, error) {
107
}
108
109
// GetDagServ returns the dagservice object this Helper is using
110
-func (db *DagBuilderHelper) GetDagServ() node.DAGService {
110
+func (db *DagBuilderHelper) GetDagServ() ipld.DAGService {
111
return db.dserv
112
}
113
@@ -194,7 +194,7 @@ func (db *DagBuilderHelper) SetPosInfo(node *UnixfsNode, offset uint64) {
194
}
195
}
196
197
-func (db *DagBuilderHelper) Add(node *UnixfsNode) (node.Node, error) {
197
+func (db *DagBuilderHelper) Add(node *UnixfsNode) (ipld.Node, error) {
198
dn, err := node.GetDagNode()
199
if err != nil {
200
return nil, err
importer/helpers/helpers.go
+4
-4
@@ -10,7 +10,7 @@ import (
10
ft "github.com/ipfs/go-ipfs/unixfs"
11
12
cid "gx/ipfs/QmcZfnkapfECQGcLZaf9B79NRg7cRa9EnZh4LSbkCzwNvY/go-cid"
13
- node "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
13
+ ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
14
)
15
16
// BlockSizeLimit specifies the maximum size an imported block can have.
@@ -81,7 +81,7 @@ func (n *UnixfsNode) Set(other *UnixfsNode) {
81
}
82
83
// GetChild gets the ith child of this node from the given DAGService.
84
-func (n *UnixfsNode) GetChild(ctx context.Context, i int, ds node.DAGService) (*UnixfsNode, error) {
84
+func (n *UnixfsNode) GetChild(ctx context.Context, i int, ds ipld.DAGService) (*UnixfsNode, error) {
85
nd, err := n.node.Links()[i].GetNode(ctx, ds)
86
if err != nil {
87
return nil, err
@@ -145,7 +145,7 @@ func (n *UnixfsNode) SetPosInfo(offset uint64, fullPath string, stat os.FileInfo
145
146
// GetDagNode fills out the proper formatting for the unixfs node
147
// inside of a DAG node and returns the dag node
148
-func (n *UnixfsNode) GetDagNode() (node.Node, error) {
148
+func (n *UnixfsNode) GetDagNode() (ipld.Node, error) {
149
nd, err := n.getBaseDagNode()
150
if err != nil {
151
return nil, err
@@ -163,7 +163,7 @@ func (n *UnixfsNode) GetDagNode() (node.Node, error) {
163
return nd, nil
164
}
165
166
-func (n *UnixfsNode) getBaseDagNode() (node.Node, error) {
166
+func (n *UnixfsNode) getBaseDagNode() (ipld.Node, error) {
167
if n.raw {
168
return n.rawnode, nil
169
}
importer/importer.go
+4
-4
@@ -12,12 +12,12 @@ import (
12
trickle "github.com/ipfs/go-ipfs/importer/trickle"
13
"gx/ipfs/QmceUdzxkimdYsgtX733uNgzf1DLHyBKN6ehGSp85ayppM/go-ipfs-cmdkit/files"
14
15
- node "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
15
+ ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
16
)
17
18
// BuildDagFromFile builds a DAG from the given file, writing created blocks to
19
// disk as they are created
20
-func BuildDagFromFile(fpath string, ds node.DAGService) (node.Node, error) {
20
+func BuildDagFromFile(fpath string, ds ipld.DAGService) (ipld.Node, error) {
21
stat, err := os.Lstat(fpath)
22
if err != nil {
23
return nil, err
@@ -38,7 +38,7 @@ func BuildDagFromFile(fpath string, ds node.DAGService) (node.Node, error) {
38
39
// BuildDagFromReader builds a DAG from the chunks returned by the given chunk
40
// splitter.
41
-func BuildDagFromReader(ds node.DAGService, spl chunk.Splitter) (node.Node, error) {
41
+func BuildDagFromReader(ds ipld.DAGService, spl chunk.Splitter) (ipld.Node, error) {
42
dbp := h.DagBuilderParams{
43
Dagserv: ds,
44
Maxlinks: h.DefaultLinksPerBlock,
@@ -48,7 +48,7 @@ func BuildDagFromReader(ds node.DAGService, spl chunk.Splitter) (node.Node, erro
48
}
49
50
// BuildTrickleDagFromReader is similar to BuildDagFromReader but uses the trickle layout.
51
-func BuildTrickleDagFromReader(ds node.DAGService, spl chunk.Splitter) (node.Node, error) {
51
+func BuildTrickleDagFromReader(ds ipld.DAGService, spl chunk.Splitter) (ipld.Node, error) {
52
dbp := h.DagBuilderParams{
53
Dagserv: ds,
54
Maxlinks: h.DefaultLinksPerBlock,
importer/importer_test.go
+4
-4
@@ -12,10 +12,10 @@ import (
12
uio "github.com/ipfs/go-ipfs/unixfs/io"
13
14
u "gx/ipfs/QmNiJuT8Ja3hMVpBHXv3Q6dwmperaQ6JjLtpMQgMCD7xvx/go-ipfs-util"
15
- node "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
15
+ ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
16
)
17
18
-func getBalancedDag(t testing.TB, size int64, blksize int64) (node.Node, node.DAGService) {
18
+func getBalancedDag(t testing.TB, size int64, blksize int64) (ipld.Node, ipld.DAGService) {
19
ds := mdtest.Mock()
20
r := io.LimitReader(u.NewTimeSeededRand(), size)
21
nd, err := BuildDagFromReader(ds, chunk.NewSizeSplitter(r, blksize))
@@ -25,7 +25,7 @@ func getBalancedDag(t testing.TB, size int64, blksize int64) (node.Node, node.DA
25
return nd, ds
26
}
27
28
-func getTrickleDag(t testing.TB, size int64, blksize int64) (node.Node, node.DAGService) {
28
+func getTrickleDag(t testing.TB, size int64, blksize int64) (ipld.Node, ipld.DAGService) {
29
ds := mdtest.Mock()
30
r := io.LimitReader(u.NewTimeSeededRand(), size)
31
nd, err := BuildTrickleDagFromReader(ds, chunk.NewSizeSplitter(r, blksize))
@@ -101,7 +101,7 @@ func BenchmarkTrickleReadFull(b *testing.B) {
101
runReadBench(b, nd, ds)
102
}
103
104
-func runReadBench(b *testing.B, nd node.Node, ds node.DAGService) {
104
+func runReadBench(b *testing.B, nd ipld.Node, ds ipld.DAGService) {
105
for i := 0; i < b.N; i++ {
106
ctx, cancel := context.WithCancel(context.Background())
107
read, err := uio.NewDagReader(ctx, nd, ds)
importer/trickle/trickle_test.go
+2
-2
@@ -17,7 +17,7 @@ import (
17
uio "github.com/ipfs/go-ipfs/unixfs/io"
18
19
u "gx/ipfs/QmNiJuT8Ja3hMVpBHXv3Q6dwmperaQ6JjLtpMQgMCD7xvx/go-ipfs-util"
20
- node "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
20
+ ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
21
)
22
23
type UseRawLeaves bool
@@ -32,7 +32,7 @@ func runBothSubtests(t *testing.T, tfunc func(*testing.T, UseRawLeaves)) {
32
t.Run("leaves=Raw", func(t *testing.T) { tfunc(t, RawLeaves) })
33
}
34
35
-func buildTestDag(ds node.DAGService, spl chunk.Splitter, rawLeaves UseRawLeaves) (*merkledag.ProtoNode, error) {
35
+func buildTestDag(ds ipld.DAGService, spl chunk.Splitter, rawLeaves UseRawLeaves) (*merkledag.ProtoNode, error) {
36
dbp := h.DagBuilderParams{
37
Dagserv: ds,
38
Maxlinks: h.DefaultLinksPerBlock,
importer/trickle/trickledag.go
+6
-6
@@ -10,7 +10,7 @@ import (
10
ft "github.com/ipfs/go-ipfs/unixfs"
11
12
cid "gx/ipfs/QmcZfnkapfECQGcLZaf9B79NRg7cRa9EnZh4LSbkCzwNvY/go-cid"
13
- node "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
13
+ ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
14
)
15
16
// layerRepeat specifies how many times to append a child tree of a
@@ -18,7 +18,7 @@ import (
18
// improves seek speeds.
19
const layerRepeat = 4
20
21
-func TrickleLayout(db *h.DagBuilderHelper) (node.Node, error) {
21
+func TrickleLayout(db *h.DagBuilderHelper) (ipld.Node, error) {
22
root := db.NewUnixfsNode()
23
if err := db.FillNodeLayer(root); err != nil {
24
return nil, err
@@ -69,7 +69,7 @@ func fillTrickleRec(db *h.DagBuilderHelper, node *h.UnixfsNode, depth int) error
69
}
70
71
// TrickleAppend appends the data in `db` to the dag, using the Trickledag format
72
-func TrickleAppend(ctx context.Context, basen node.Node, db *h.DagBuilderHelper) (out node.Node, err_out error) {
72
+func TrickleAppend(ctx context.Context, basen ipld.Node, db *h.DagBuilderHelper) (out ipld.Node, err_out error) {
73
base, ok := basen.(*dag.ProtoNode)
74
if !ok {
75
return nil, dag.ErrNotProtobuf
@@ -237,7 +237,7 @@ func trickleDepthInfo(node *h.UnixfsNode, maxlinks int) (int, int) {
237
238
// VerifyParams is used by VerifyTrickleDagStructure
239
type VerifyParams struct {
240
- Getter node.NodeGetter
240
+ Getter ipld.NodeGetter
241
Direct int
242
LayerRepeat int
243
Prefix *cid.Prefix
@@ -246,12 +246,12 @@ type VerifyParams struct {
246
247
// VerifyTrickleDagStructure checks that the given dag matches exactly the trickle dag datastructure
248
// layout
249
-func VerifyTrickleDagStructure(nd node.Node, p VerifyParams) error {
249
+func VerifyTrickleDagStructure(nd ipld.Node, p VerifyParams) error {
250
return verifyTDagRec(nd, -1, p)
251
}
252
253
// Recursive call for verifying the structure of a trickledag
254
-func verifyTDagRec(n node.Node, depth int, p VerifyParams) error {
254
+func verifyTDagRec(n ipld.Node, depth int, p VerifyParams) error {
255
codec := cid.DagProtobuf
256
if depth == 0 {
257
if len(n.Links()) > 0 {
merkledag/coding.go
+5
-5
@@ -10,7 +10,7 @@ import (
10
pb "github.com/ipfs/go-ipfs/merkledag/pb"
11
12
cid "gx/ipfs/QmcZfnkapfECQGcLZaf9B79NRg7cRa9EnZh4LSbkCzwNvY/go-cid"
13
- node "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
13
+ ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
14
)
15
16
// for now, we use a PBNode intermediate thing.
@@ -25,9 +25,9 @@ func (n *ProtoNode) unmarshal(encoded []byte) error {
25
}
26
27
pbnl := pbn.GetLinks()
28
- n.links = make([]*node.Link, len(pbnl))
28
+ n.links = make([]*ipld.Link, len(pbnl))
29
for i, l := range pbnl {
30
- n.links[i] = &node.Link{Name: l.GetName(), Size: l.GetTsize()}
30
+ n.links[i] = &ipld.Link{Name: l.GetName(), Size: l.GetTsize()}
31
c, err := cid.Cast(l.GetHash())
32
if err != nil {
33
return fmt.Errorf("Link hash #%d is not valid multihash. %v", i, err)
@@ -114,7 +114,7 @@ func DecodeProtobuf(encoded []byte) (*ProtoNode, error) {
114
115
// DecodeProtobufBlock is a block decoder for protobuf IPLD nodes conforming to
116
// node.DecodeBlockFunc
117
-func DecodeProtobufBlock(b blocks.Block) (node.Node, error) {
117
+func DecodeProtobufBlock(b blocks.Block) (ipld.Node, error) {
118
c := b.Cid()
119
if c.Type() != cid.DagProtobuf {
120
return nil, fmt.Errorf("this function can only decode protobuf nodes")
@@ -134,4 +134,4 @@ func DecodeProtobufBlock(b blocks.Block) (node.Node, error) {
134
}
135
136
// Type assertion
137
-var _ node.DecodeBlockFunc = DecodeProtobufBlock
137
+var _ ipld.DecodeBlockFunc = DecodeProtobufBlock
merkledag/merkledag.go
+36
-36
@@ -10,7 +10,7 @@ import (
10
11
ipldcbor "gx/ipfs/QmNRz7BDWfdFNVLt7AVvmRefkrURD25EeoipcXqo6yoXU1/go-ipld-cbor"
12
cid "gx/ipfs/QmcZfnkapfECQGcLZaf9B79NRg7cRa9EnZh4LSbkCzwNvY/go-cid"
13
- node "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
13
+ ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
14
blocks "gx/ipfs/Qmej7nf81hi2x2tvjRBF3mcp74sQyuDH4VMYDGd1YtXjb2/go-block-format"
15
)
16
@@ -18,9 +18,9 @@ import (
18
// functionality should go in a `go-ipld` repo but that will take a lot of work
19
// and design.
20
func init() {
21
- node.Register(cid.DagProtobuf, DecodeProtobufBlock)
22
- node.Register(cid.Raw, DecodeRawBlock)
23
- node.Register(cid.DagCBOR, ipldcbor.DecodeBlock)
21
+ ipld.Register(cid.DagProtobuf, DecodeProtobufBlock)
22
+ ipld.Register(cid.Raw, DecodeRawBlock)
23
+ ipld.Register(cid.DagCBOR, ipldcbor.DecodeBlock)
24
}
25
26
// NewDAGService constructs a new DAGService (using the default implementation).
@@ -38,7 +38,7 @@ type dagService struct {
38
}
39
40
// Add adds a node to the dagService, storing the block in the BlockService
41
-func (n *dagService) Add(ctx context.Context, nd node.Node) error {
41
+func (n *dagService) Add(ctx context.Context, nd ipld.Node) error {
42
if n == nil { // FIXME remove this assertion. protect with constructor invariant
43
return fmt.Errorf("dagService is nil")
44
}
@@ -46,7 +46,7 @@ func (n *dagService) Add(ctx context.Context, nd node.Node) error {
46
return n.Blocks.AddBlock(nd)
47
}
48
49
-func (n *dagService) AddMany(ctx context.Context, nds []node.Node) error {
49
+func (n *dagService) AddMany(ctx context.Context, nds []ipld.Node) error {
50
blks := make([]blocks.Block, len(nds))
51
for i, nd := range nds {
52
blks[i] = nd
@@ -55,7 +55,7 @@ func (n *dagService) AddMany(ctx context.Context, nds []node.Node) error {
55
}
56
57
// Get retrieves a node from the dagService, fetching the block in the BlockService
58
-func (n *dagService) Get(ctx context.Context, c *cid.Cid) (node.Node, error) {
58
+func (n *dagService) Get(ctx context.Context, c *cid.Cid) (ipld.Node, error) {
59
if n == nil {
60
return nil, fmt.Errorf("dagService is nil")
61
}
@@ -66,17 +66,17 @@ func (n *dagService) Get(ctx context.Context, c *cid.Cid) (node.Node, error) {
66
b, err := n.Blocks.GetBlock(ctx, c)
67
if err != nil {
68
if err == bserv.ErrNotFound {
69
- return nil, node.ErrNotFound
69
+ return nil, ipld.ErrNotFound
70
}
71
return nil, fmt.Errorf("Failed to get block for %s: %v", c, err)
72
}
73
74
- return node.Decode(b)
74
+ return ipld.Decode(b)
75
}
76
77
// GetLinks return the links for the node, the node doesn't necessarily have
78
// to exist locally.
79
-func (n *dagService) GetLinks(ctx context.Context, c *cid.Cid) ([]*node.Link, error) {
79
+func (n *dagService) GetLinks(ctx context.Context, c *cid.Cid) ([]*ipld.Link, error) {
80
if c.Type() == cid.Raw {
81
return nil, nil
82
}
@@ -109,12 +109,12 @@ func (n *dagService) RemoveMany(ctx context.Context, cids []*cid.Cid) error {
109
// GetLinksDirect creates a function to get the links for a node, from
110
// the node, bypassing the LinkService. If the node does not exist
111
// locally (and can not be retrieved) an error will be returned.
112
-func GetLinksDirect(serv node.NodeGetter) GetLinks {
113
- return func(ctx context.Context, c *cid.Cid) ([]*node.Link, error) {
112
+func GetLinksDirect(serv ipld.NodeGetter) GetLinks {
113
+ return func(ctx context.Context, c *cid.Cid) ([]*ipld.Link, error) {
114
nd, err := serv.Get(ctx, c)
115
if err != nil {
116
if err == bserv.ErrNotFound {
117
- err = node.ErrNotFound
117
+ err = ipld.ErrNotFound
118
}
119
return nil, err
120
}
@@ -127,28 +127,28 @@ type sesGetter struct {
127
}
128
129
// Get gets a single node from the DAG.
130
-func (sg *sesGetter) Get(ctx context.Context, c *cid.Cid) (node.Node, error) {
130
+func (sg *sesGetter) Get(ctx context.Context, c *cid.Cid) (ipld.Node, error) {
131
blk, err := sg.bs.GetBlock(ctx, c)
132
switch err {
133
case bserv.ErrNotFound:
134
- return nil, node.ErrNotFound
134
+ return nil, ipld.ErrNotFound
135
default:
136
return nil, err
137
case nil:
138
// noop
139
}
140
141
- return node.Decode(blk)
141
+ return ipld.Decode(blk)
142
}
143
144
// GetMany gets many nodes at once, batching the request if possible.
145
-func (sg *sesGetter) GetMany(ctx context.Context, keys []*cid.Cid) <-chan *node.NodeOption {
145
+func (sg *sesGetter) GetMany(ctx context.Context, keys []*cid.Cid) <-chan *ipld.NodeOption {
146
return getNodesFromBG(ctx, sg.bs, keys)
147
}
148
149
// FetchGraph fetches all nodes that are children of the given node
150
-func FetchGraph(ctx context.Context, root *cid.Cid, serv node.DAGService) error {
151
- var ng node.NodeGetter = serv
150
+func FetchGraph(ctx context.Context, root *cid.Cid, serv ipld.DAGService) error {
151
+ var ng ipld.NodeGetter = serv
152
ds, ok := serv.(*dagService)
153
if ok {
154
ng = &sesGetter{bserv.NewSession(ctx, ds.Blocks)}
@@ -187,12 +187,12 @@ func FindLinks(links []*cid.Cid, c *cid.Cid, start int) []int {
187
// This method may not return all requested nodes (and may or may not return an
188
// error indicating that it failed to do so. It is up to the caller to verify
189
// that it received all nodes.
190
-func (n *dagService) GetMany(ctx context.Context, keys []*cid.Cid) <-chan *node.NodeOption {
190
+func (n *dagService) GetMany(ctx context.Context, keys []*cid.Cid) <-chan *ipld.NodeOption {
191
return getNodesFromBG(ctx, n.Blocks, keys)
192
}
193
194
-func getNodesFromBG(ctx context.Context, bs bserv.BlockGetter, keys []*cid.Cid) <-chan *node.NodeOption {
195
- out := make(chan *node.NodeOption, len(keys))
194
+func getNodesFromBG(ctx context.Context, bs bserv.BlockGetter, keys []*cid.Cid) <-chan *ipld.NodeOption {
195
+ out := make(chan *ipld.NodeOption, len(keys))
196
blocks := bs.GetBlocks(ctx, keys)
197
var count int
198
@@ -203,22 +203,22 @@ func getNodesFromBG(ctx context.Context, bs bserv.BlockGetter, keys []*cid.Cid)
203
case b, ok := <-blocks:
204
if !ok {
205
if count != len(keys) {
206
- out <- &node.NodeOption{Err: fmt.Errorf("failed to fetch all nodes")}
206
+ out <- &ipld.NodeOption{Err: fmt.Errorf("failed to fetch all nodes")}
207
}
208
return
209
}
210
211
- nd, err := node.Decode(b)
211
+ nd, err := ipld.Decode(b)
212
if err != nil {
213
- out <- &node.NodeOption{Err: err}
213
+ out <- &ipld.NodeOption{Err: err}
214
return
215
}
216
217
- out <- &node.NodeOption{Node: nd}
217
+ out <- &ipld.NodeOption{Node: nd}
218
count++
219
220
case <-ctx.Done():
221
- out <- &node.NodeOption{Err: ctx.Err()}
221
+ out <- &ipld.NodeOption{Err: ctx.Err()}
222
return
223
}
224
}
@@ -228,15 +228,15 @@ func getNodesFromBG(ctx context.Context, bs bserv.BlockGetter, keys []*cid.Cid)
228
229
// GetLinks is the type of function passed to the EnumerateChildren function(s)
230
// for getting the children of an IPLD node.
231
-type GetLinks func(context.Context, *cid.Cid) ([]*node.Link, error)
231
+type GetLinks func(context.Context, *cid.Cid) ([]*ipld.Link, error)
232
233
// GetLinksWithDAG returns a GetLinks function that tries to use the given
234
// NodeGetter as a LinkGetter to get the children of a given IPLD node. This may
235
// allow us to traverse the DAG without actually loading and parsing the node in
236
// question (if we already have the links cached).
237
-func GetLinksWithDAG(ng node.NodeGetter) GetLinks {
238
- return func(ctx context.Context, c *cid.Cid) ([]*node.Link, error) {
239
- return node.GetLinks(ctx, ng, c)
237
+func GetLinksWithDAG(ng ipld.NodeGetter) GetLinks {
238
+ return func(ctx context.Context, c *cid.Cid) ([]*ipld.Link, error) {
239
+ return ipld.GetLinks(ctx, ng, c)
240
}
241
}
242
@@ -291,7 +291,7 @@ var FetchGraphConcurrency = 8
291
// NOTE: It *does not* make multiple concurrent calls to the passed `visit` function.
292
func EnumerateChildrenAsync(ctx context.Context, getLinks GetLinks, c *cid.Cid, visit func(*cid.Cid) bool) error {
293
feed := make(chan *cid.Cid)
294
- out := make(chan []*node.Link)
294
+ out := make(chan []*ipld.Link)
295
done := make(chan struct{})
296
297
var setlk sync.Mutex
@@ -370,7 +370,7 @@ func EnumerateChildrenAsync(ctx context.Context, getLinks GetLinks, c *cid.Cid,
370
371
}
372
373
-var _ node.LinkGetter = &dagService{}
374
-var _ node.NodeGetter = &dagService{}
375
-var _ node.NodeGetter = &sesGetter{}
376
-var _ node.DAGService = &dagService{}
373
+var _ ipld.LinkGetter = &dagService{}
374
+var _ ipld.NodeGetter = &dagService{}
375
+var _ ipld.NodeGetter = &sesGetter{}
376
+var _ ipld.DAGService = &dagService{}
merkledag/merkledag_test.go
+10
-10
@@ -26,7 +26,7 @@ import (
26
27
u "gx/ipfs/QmNiJuT8Ja3hMVpBHXv3Q6dwmperaQ6JjLtpMQgMCD7xvx/go-ipfs-util"
28
cid "gx/ipfs/QmcZfnkapfECQGcLZaf9B79NRg7cRa9EnZh4LSbkCzwNvY/go-cid"
29
- node "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
29
+ ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
30
)
31
32
func TestNode(t *testing.T) {
@@ -88,7 +88,7 @@ func SubtestNodeStat(t *testing.T, n *ProtoNode) {
88
89
k := n.Cid()
90
91
- expected := node.NodeStat{
91
+ expected := ipld.NodeStat{
92
NumLinks: len(n.Links()),
93
BlockSize: len(enc),
94
LinksSize: len(enc) - len(n.Data()), // includes framing.
@@ -131,7 +131,7 @@ func TestBatchFetchDupBlock(t *testing.T) {
131
132
func runBatchFetchTest(t *testing.T, read io.Reader) {
133
ctx := context.Background()
134
- var dagservs []node.DAGService
134
+ var dagservs []ipld.DAGService
135
for _, bsi := range bstest.Mocks(5) {
136
dagservs = append(dagservs, NewDAGService(bsi))
137
}
@@ -221,7 +221,7 @@ func TestCantGet(t *testing.T) {
221
}
222
223
func TestFetchGraph(t *testing.T) {
224
- var dservs []node.DAGService
224
+ var dservs []ipld.DAGService
225
bsis := bstest.Mocks(2)
226
for _, bsi := range bsis {
227
dservs = append(dservs, NewDAGService(bsi))
@@ -265,8 +265,8 @@ func TestEnumerateChildren(t *testing.T) {
265
t.Fatal(err)
266
}
267
268
- var traverse func(n node.Node)
269
- traverse = func(n node.Node) {
268
+ var traverse func(n ipld.Node)
269
+ traverse = func(n ipld.Node) {
270
// traverse dag and check
271
for _, lnk := range n.Links() {
272
c := lnk.Cid
@@ -317,7 +317,7 @@ func TestFetchFailure(t *testing.T) {
317
}
318
}
319
320
- getters := node.GetDAG(ctx, ds, top)
320
+ getters := ipld.GetDAG(ctx, ds, top)
321
for i, getter := range getters {
322
_, err := getter.Get(ctx)
323
if err != nil && i < 10 {
@@ -433,7 +433,7 @@ func TestGetRawNodes(t *testing.T) {
433
func TestProtoNodeResolve(t *testing.T) {
434
435
nd := new(ProtoNode)
436
- nd.SetLinks([]*node.Link{{Name: "foo"}})
436
+ nd.SetLinks([]*ipld.Link{{Name: "foo"}})
437
438
lnk, left, err := nd.ResolveLink([]string{"foo", "bar"})
439
if err != nil {
@@ -517,7 +517,7 @@ func TestEnumerateAsyncFailsNotFound(t *testing.T) {
517
d := NodeWithData([]byte("foo4"))
518
519
ds := dstest.Mock()
520
- for _, n := range []node.Node{a, b, c} {
520
+ for _, n := range []ipld.Node{a, b, c} {
521
err := ds.Add(ctx, n)
522
if err != nil {
523
t.Fatal(err)
@@ -580,7 +580,7 @@ func testProgressIndicator(t *testing.T, depth int) {
580
}
581
}
582
583
-func mkDag(ds node.DAGService, depth int) (*cid.Cid, int) {
583
+func mkDag(ds ipld.DAGService, depth int) (*cid.Cid, int) {
584
ctx := context.Background()
585
586
totalChildren := 0
merkledag/node.go
+23
-23
@@ -7,7 +7,7 @@ import (
7
8
mh "gx/ipfs/QmZyZDi491cCNTLfAhwcaDii2Kg4pwKRkhqQzURGDvY6ua/go-multihash"
9
cid "gx/ipfs/QmcZfnkapfECQGcLZaf9B79NRg7cRa9EnZh4LSbkCzwNvY/go-cid"
10
- node "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
10
+ ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
11
)
12
13
var ErrNotProtobuf = fmt.Errorf("expected protobuf dag node")
@@ -16,7 +16,7 @@ var ErrLinkNotFound = fmt.Errorf("no link by that name")
16
// Node represents a node in the IPFS Merkle DAG.
17
// nodes have opaque data and a set of navigable links.
18
type ProtoNode struct {
19
- links []*node.Link
19
+ links []*ipld.Link
20
data []byte
21
22
// cache encoded/marshaled value
@@ -73,7 +73,7 @@ func (n *ProtoNode) SetPrefix(prefix *cid.Prefix) {
73
}
74
}
75
76
-type LinkSlice []*node.Link
76
+type LinkSlice []*ipld.Link
77
78
func (ls LinkSlice) Len() int { return len(ls) }
79
func (ls LinkSlice) Swap(a, b int) { ls[a], ls[b] = ls[b], ls[a] }
@@ -84,10 +84,10 @@ func NodeWithData(d []byte) *ProtoNode {
84
}
85
86
// AddNodeLink adds a link to another node.
87
-func (n *ProtoNode) AddNodeLink(name string, that node.Node) error {
87
+func (n *ProtoNode) AddNodeLink(name string, that ipld.Node) error {
88
n.encoded = nil
89
90
- lnk, err := node.MakeLink(that)
90
+ lnk, err := ipld.MakeLink(that)
91
if err != nil {
92
return err
93
}
@@ -101,9 +101,9 @@ func (n *ProtoNode) AddNodeLink(name string, that node.Node) error {
101
102
// AddNodeLinkClean adds a link to another node. without keeping a reference to
103
// the child node
104
-func (n *ProtoNode) AddNodeLinkClean(name string, that node.Node) error {
104
+func (n *ProtoNode) AddNodeLinkClean(name string, that ipld.Node) error {
105
n.encoded = nil
106
- lnk, err := node.MakeLink(that)
106
+ lnk, err := ipld.MakeLink(that)
107
if err != nil {
108
return err
109
}
@@ -113,9 +113,9 @@ func (n *ProtoNode) AddNodeLinkClean(name string, that node.Node) error {
113
}
114
115
// AddRawLink adds a copy of a link to this node
116
-func (n *ProtoNode) AddRawLink(name string, l *node.Link) error {
116
+func (n *ProtoNode) AddRawLink(name string, l *ipld.Link) error {
117
n.encoded = nil
118
- n.links = append(n.links, &node.Link{
118
+ n.links = append(n.links, &ipld.Link{
119
Name: name,
120
Size: l.Size,
121
Cid: l.Cid,
@@ -127,7 +127,7 @@ func (n *ProtoNode) AddRawLink(name string, l *node.Link) error {
127
// RemoveNodeLink removes a link on this node by the given name.
128
func (n *ProtoNode) RemoveNodeLink(name string) error {
129
n.encoded = nil
130
- good := make([]*node.Link, 0, len(n.links))
130
+ good := make([]*ipld.Link, 0, len(n.links))
131
var found bool
132
133
for _, l := range n.links {
@@ -140,17 +140,17 @@ func (n *ProtoNode) RemoveNodeLink(name string) error {
140
n.links = good
141
142
if !found {
143
- return node.ErrNotFound
143
+ return ipld.ErrNotFound
144
}
145
146
return nil
147
}
148
149
// GetNodeLink returns a copy of the link with the given name.
150
-func (n *ProtoNode) GetNodeLink(name string) (*node.Link, error) {
150
+func (n *ProtoNode) GetNodeLink(name string) (*ipld.Link, error) {
151
for _, l := range n.links {
152
if l.Name == name {
153
- return &node.Link{
153
+ return &ipld.Link{
154
Name: l.Name,
155
Size: l.Size,
156
Cid: l.Cid,
@@ -161,7 +161,7 @@ func (n *ProtoNode) GetNodeLink(name string) (*node.Link, error) {
161
}
162
163
// GetLinkedProtoNode returns a copy of the ProtoNode with the given name.
164
-func (n *ProtoNode) GetLinkedProtoNode(ctx context.Context, ds node.DAGService, name string) (*ProtoNode, error) {
164
+func (n *ProtoNode) GetLinkedProtoNode(ctx context.Context, ds ipld.DAGService, name string) (*ProtoNode, error) {
165
nd, err := n.GetLinkedNode(ctx, ds, name)
166
if err != nil {
167
return nil, err
@@ -176,7 +176,7 @@ func (n *ProtoNode) GetLinkedProtoNode(ctx context.Context, ds node.DAGService,
176
}
177
178
// GetLinkedNode returns a copy of the IPLD Node with the given name.
179
-func (n *ProtoNode) GetLinkedNode(ctx context.Context, ds node.DAGService, name string) (node.Node, error) {
179
+func (n *ProtoNode) GetLinkedNode(ctx context.Context, ds ipld.DAGService, name string) (ipld.Node, error) {
180
lnk, err := n.GetNodeLink(name)
181
if err != nil {
182
return nil, err
@@ -187,7 +187,7 @@ func (n *ProtoNode) GetLinkedNode(ctx context.Context, ds node.DAGService, name
187
188
// Copy returns a copy of the node.
189
// NOTE: Does not make copies of Node objects in the links.
190
-func (n *ProtoNode) Copy() node.Node {
190
+func (n *ProtoNode) Copy() ipld.Node {
191
nnode := new(ProtoNode)
192
if len(n.data) > 0 {
193
nnode.data = make([]byte, len(n.data))
@@ -195,7 +195,7 @@ func (n *ProtoNode) Copy() node.Node {
195
}
196
197
if len(n.links) > 0 {
198
- nnode.links = make([]*node.Link, len(n.links))
198
+ nnode.links = make([]*ipld.Link, len(n.links))
199
copy(nnode.links, n.links)
200
}
201
@@ -244,7 +244,7 @@ func (n *ProtoNode) Size() (uint64, error) {
244
}
245
246
// Stat returns statistics on the node.
247
-func (n *ProtoNode) Stat() (*node.NodeStat, error) {
247
+func (n *ProtoNode) Stat() (*ipld.NodeStat, error) {
248
enc, err := n.EncodeProtobuf(false)
249
if err != nil {
250
return nil, err
@@ -255,7 +255,7 @@ func (n *ProtoNode) Stat() (*node.NodeStat, error) {
255
return nil, err
256
}
257
258
- return &node.NodeStat{
258
+ return &ipld.NodeStat{
259
Hash: n.Cid().String(),
260
NumLinks: len(n.links),
261
BlockSize: len(enc),
@@ -274,7 +274,7 @@ func (n *ProtoNode) Loggable() map[string]interface{} {
274
func (n *ProtoNode) UnmarshalJSON(b []byte) error {
275
s := struct {
276
Data []byte `json:"data"`
277
- Links []*node.Link `json:"links"`
277
+ Links []*ipld.Link `json:"links"`
278
}{}
279
280
err := json.Unmarshal(b, &s)
@@ -332,11 +332,11 @@ func (n *ProtoNode) Multihash() mh.Multihash {
332
return n.cached.Hash()
333
}
334
335
-func (n *ProtoNode) Links() []*node.Link {
335
+func (n *ProtoNode) Links() []*ipld.Link {
336
return n.links
337
}
338
339
-func (n *ProtoNode) SetLinks(links []*node.Link) {
339
+func (n *ProtoNode) SetLinks(links []*ipld.Link) {
340
n.links = links
341
}
342
@@ -344,7 +344,7 @@ func (n *ProtoNode) Resolve(path []string) (interface{}, []string, error) {
344
return n.ResolveLink(path)
345
}
346
347
-func (n *ProtoNode) ResolveLink(path []string) (*node.Link, []string, error) {
347
+func (n *ProtoNode) ResolveLink(path []string) (*ipld.Link, []string, error) {
348
if len(path) == 0 {
349
return nil, nil, fmt.Errorf("end of path, no more links to resolve")
350
}
merkledag/node_test.go
+6
-6
@@ -8,12 +8,12 @@ import (
8
. "github.com/ipfs/go-ipfs/merkledag"
9
mdtest "github.com/ipfs/go-ipfs/merkledag/test"
10
11
- node "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
11
+ ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
12
)
13
14
func TestRemoveLink(t *testing.T) {
15
nd := &ProtoNode{}
16
- nd.SetLinks([]*node.Link{
16
+ nd.SetLinks([]*ipld.Link{
17
{Name: "a"},
18
{Name: "b"},
19
{Name: "a"},
@@ -41,7 +41,7 @@ func TestRemoveLink(t *testing.T) {
41
42
// should fail
43
err = nd.RemoveNodeLink("a")
44
- if err != node.ErrNotFound {
44
+ if err != ipld.ErrNotFound {
45
t.Fatal("should have failed to remove link")
46
}
47
@@ -72,7 +72,7 @@ func TestFindLink(t *testing.T) {
72
kEmpty := ndEmpty.Cid()
73
74
nd := &ProtoNode{}
75
- nd.SetLinks([]*node.Link{
75
+ nd.SetLinks([]*ipld.Link{
76
{Name: "a", Cid: kEmpty},
77
{Name: "c", Cid: kEmpty},
78
{Name: "b", Cid: kEmpty},
@@ -119,7 +119,7 @@ func TestFindLink(t *testing.T) {
119
120
func TestNodeCopy(t *testing.T) {
121
nd := &ProtoNode{}
122
- nd.SetLinks([]*node.Link{
122
+ nd.SetLinks([]*ipld.Link{
123
{Name: "a"},
124
{Name: "c"},
125
{Name: "b"},
@@ -137,7 +137,7 @@ func TestNodeCopy(t *testing.T) {
137
138
func TestJsonRoundtrip(t *testing.T) {
139
nd := new(ProtoNode)
140
- nd.SetLinks([]*node.Link{
140
+ nd.SetLinks([]*ipld.Link{
141
{Name: "a"},
142
{Name: "c"},
143
{Name: "b"},
merkledag/raw.go
+9
-9
@@ -6,7 +6,7 @@ import (
6
7
u "gx/ipfs/QmNiJuT8Ja3hMVpBHXv3Q6dwmperaQ6JjLtpMQgMCD7xvx/go-ipfs-util"
8
cid "gx/ipfs/QmcZfnkapfECQGcLZaf9B79NRg7cRa9EnZh4LSbkCzwNvY/go-cid"
9
- node "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
9
+ ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
10
)
11
12
type RawNode struct {
@@ -24,7 +24,7 @@ func NewRawNode(data []byte) *RawNode {
24
}
25
26
// DecodeRawBlock is a block decoder for raw IPLD nodes conforming to `node.DecodeBlockFunc`.
27
-func DecodeRawBlock(block blocks.Block) (node.Node, error) {
27
+func DecodeRawBlock(block blocks.Block) (ipld.Node, error) {
28
if block.Cid().Type() != cid.Raw {
29
return nil, fmt.Errorf("raw nodes cannot be decoded from non-raw blocks: %d", block.Cid().Type())
30
}
@@ -32,7 +32,7 @@ func DecodeRawBlock(block blocks.Block) (node.Node, error) {
32
return &RawNode{block}, nil
33
}
34
35
-var _ node.DecodeBlockFunc = DecodeRawBlock
35
+var _ ipld.DecodeBlockFunc = DecodeRawBlock
36
37
// NewRawNodeWPrefix creates a RawNode with the hash function
38
// specified in prefix.
@@ -52,11 +52,11 @@ func NewRawNodeWPrefix(data []byte, prefix cid.Prefix) (*RawNode, error) {
52
return &RawNode{blk}, nil
53
}
54
55
-func (rn *RawNode) Links() []*node.Link {
55
+func (rn *RawNode) Links() []*ipld.Link {
56
return nil
57
}
58
59
-func (rn *RawNode) ResolveLink(path []string) (*node.Link, []string, error) {
59
+func (rn *RawNode) ResolveLink(path []string) (*ipld.Link, []string, error) {
60
return nil, nil, ErrLinkNotFound
61
}
62
@@ -68,7 +68,7 @@ func (rn *RawNode) Tree(p string, depth int) []string {
68
return nil
69
}
70
71
-func (rn *RawNode) Copy() node.Node {
71
+func (rn *RawNode) Copy() ipld.Node {
72
copybuf := make([]byte, len(rn.RawData()))
73
copy(copybuf, rn.RawData())
74
nblk, err := blocks.NewBlockWithCid(rn.RawData(), rn.Cid())
@@ -84,11 +84,11 @@ func (rn *RawNode) Size() (uint64, error) {
84
return uint64(len(rn.RawData())), nil
85
}
86
87
-func (rn *RawNode) Stat() (*node.NodeStat, error) {
88
- return &node.NodeStat{
87
+func (rn *RawNode) Stat() (*ipld.NodeStat, error) {
88
+ return &ipld.NodeStat{
89
CumulativeSize: len(rn.RawData()),
90
DataSize: len(rn.RawData()),
91
}, nil
92
}
93
94
-var _ node.Node = (*RawNode)(nil)
94
+var _ ipld.Node = (*RawNode)(nil)
merkledag/test/utils.go
+2
-2
@@ -8,11 +8,11 @@ import (
8
9
ds "gx/ipfs/QmPpegoMqhAEqjncrzArm7KVWAkCm78rqL2DPuNjhPrshg/go-datastore"
10
dssync "gx/ipfs/QmPpegoMqhAEqjncrzArm7KVWAkCm78rqL2DPuNjhPrshg/go-datastore/sync"
11
- node "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
11
+ ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
12
)
13
14
// Mock returns a new thread-safe, mock DAGService.
15
-func Mock() node.DAGService {
15
+func Mock() ipld.DAGService {
16
return dag.NewDAGService(Bserv())
17
}
18
merkledag/traverse/traverse.go
+7
-7
@@ -5,7 +5,7 @@ import (
5
"context"
6
"errors"
7
8
- node "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
8
+ ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
9
)
10
11
// Order is an identifier for traversal algorithm orders
@@ -19,7 +19,7 @@ const (
19
20
// Options specifies a series of traversal options
21
type Options struct {
22
- DAG node.NodeGetter // the dagservice to fetch nodes
22
+ DAG ipld.NodeGetter // the dagservice to fetch nodes
23
Order Order // what order to traverse in
24
Func Func // the function to perform at each step
25
ErrFunc ErrFunc // see ErrFunc. Optional
@@ -29,7 +29,7 @@ type Options struct {
29
30
// State is a current traversal state
31
type State struct {
32
- Node node.Node
32
+ Node ipld.Node
33
Depth int
34
}
35
@@ -38,7 +38,7 @@ type traversal struct {
38
seen map[string]struct{}
39
}
40
41
-func (t *traversal) shouldSkip(n node.Node) (bool, error) {
41
+func (t *traversal) shouldSkip(n ipld.Node) (bool, error) {
42
if t.opts.SkipDuplicates {
43
k := n.Cid()
44
if _, found := t.seen[k.KeyString()]; found {
@@ -58,9 +58,9 @@ func (t *traversal) callFunc(next State) error {
58
// stop processing. if it returns a nil node, just skip it.
59
//
60
// the error handling is a little complicated.
61
-func (t *traversal) getNode(link *node.Link) (node.Node, error) {
61
+func (t *traversal) getNode(link *ipld.Link) (ipld.Node, error) {
62
63
- getNode := func(l *node.Link) (node.Node, error) {
63
+ getNode := func(l *ipld.Link) (ipld.Node, error) {
64
next, err := l.GetNode(context.TODO(), t.opts.DAG)
65
if err != nil {
66
return nil, err
@@ -98,7 +98,7 @@ type Func func(current State) error
98
//
99
type ErrFunc func(err error) error
100
101
-func Traverse(root node.Node, o Options) error {
101
+func Traverse(root ipld.Node, o Options) error {
102
t := traversal{
103
opts: o,
104
seen: map[string]struct{}{},
merkledag/traverse/traverse_test.go
+8
-8
@@ -9,7 +9,7 @@ import (
9
mdag "github.com/ipfs/go-ipfs/merkledag"
10
mdagtest "github.com/ipfs/go-ipfs/merkledag/test"
11
12
- node "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
12
+ ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
13
)
14
15
func TestDFSPreNoSkip(t *testing.T) {
@@ -324,7 +324,7 @@ func TestBFSSkip(t *testing.T) {
324
`))
325
}
326
327
-func testWalkOutputs(t *testing.T, root node.Node, opts Options, expect []byte) {
327
+func testWalkOutputs(t *testing.T, root ipld.Node, opts Options, expect []byte) {
328
expect = bytes.TrimLeft(expect, "\n")
329
330
buf := new(bytes.Buffer)
@@ -351,7 +351,7 @@ func testWalkOutputs(t *testing.T, root node.Node, opts Options, expect []byte)
351
}
352
}
353
354
-func newFan(t *testing.T, ds node.DAGService) node.Node {
354
+func newFan(t *testing.T, ds ipld.DAGService) ipld.Node {
355
a := mdag.NodeWithData([]byte("/a"))
356
addLink(t, ds, a, child(t, ds, a, "aa"))
357
addLink(t, ds, a, child(t, ds, a, "ab"))
@@ -360,7 +360,7 @@ func newFan(t *testing.T, ds node.DAGService) node.Node {
360
return a
361
}
362
363
-func newLinkedList(t *testing.T, ds node.DAGService) node.Node {
363
+func newLinkedList(t *testing.T, ds ipld.DAGService) ipld.Node {
364
a := mdag.NodeWithData([]byte("/a"))
365
aa := child(t, ds, a, "aa")
366
aaa := child(t, ds, aa, "aaa")
@@ -373,7 +373,7 @@ func newLinkedList(t *testing.T, ds node.DAGService) node.Node {
373
return a
374
}
375
376
-func newBinaryTree(t *testing.T, ds node.DAGService) node.Node {
376
+func newBinaryTree(t *testing.T, ds ipld.DAGService) ipld.Node {
377
a := mdag.NodeWithData([]byte("/a"))
378
aa := child(t, ds, a, "aa")
379
ab := child(t, ds, a, "ab")
@@ -386,7 +386,7 @@ func newBinaryTree(t *testing.T, ds node.DAGService) node.Node {
386
return a
387
}
388
389
-func newBinaryDAG(t *testing.T, ds node.DAGService) node.Node {
389
+func newBinaryDAG(t *testing.T, ds ipld.DAGService) ipld.Node {
390
a := mdag.NodeWithData([]byte("/a"))
391
aa := child(t, ds, a, "aa")
392
aaa := child(t, ds, aa, "aaa")
@@ -403,7 +403,7 @@ func newBinaryDAG(t *testing.T, ds node.DAGService) node.Node {
403
return a
404
}
405
406
-func addLink(t *testing.T, ds node.DAGService, a, b node.Node) {
406
+func addLink(t *testing.T, ds ipld.DAGService, a, b ipld.Node) {
407
to := string(a.(*mdag.ProtoNode).Data()) + "2" + string(b.(*mdag.ProtoNode).Data())
408
if err := ds.Add(context.Background(), b); err != nil {
409
t.Error(err)
@@ -413,6 +413,6 @@ func addLink(t *testing.T, ds node.DAGService, a, b node.Node) {
413
}
414
}
415
416
-func child(t *testing.T, ds node.DAGService, a node.Node, name string) node.Node {
416
+func child(t *testing.T, ds ipld.DAGService, a ipld.Node, name string) ipld.Node {
417
return mdag.NodeWithData([]byte(string(a.(*mdag.ProtoNode).Data()) + "/" + name))
418
}
merkledag/utils/diff.go
+3
-3
@@ -8,7 +8,7 @@ import (
8
dag "github.com/ipfs/go-ipfs/merkledag"
9
10
cid "gx/ipfs/QmcZfnkapfECQGcLZaf9B79NRg7cRa9EnZh4LSbkCzwNvY/go-cid"
11
- node "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
11
+ ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
12
)
13
14
const (
@@ -38,7 +38,7 @@ func (c *Change) String() string {
38
}
39
40
// ApplyChange applies the requested changes to the given node in the given dag.
41
-func ApplyChange(ctx context.Context, ds node.DAGService, nd *dag.ProtoNode, cs []*Change) (*dag.ProtoNode, error) {
41
+func ApplyChange(ctx context.Context, ds ipld.DAGService, nd *dag.ProtoNode, cs []*Change) (*dag.ProtoNode, error) {
42
e := NewDagEditor(nd, ds)
43
for _, c := range cs {
44
switch c.Type {
@@ -90,7 +90,7 @@ func ApplyChange(ctx context.Context, ds node.DAGService, nd *dag.ProtoNode, cs
90
}
91
92
// Diff returns a set of changes that transform node 'a' into node 'b'
93
-func Diff(ctx context.Context, ds node.DAGService, a, b node.Node) ([]*Change, error) {
93
+func Diff(ctx context.Context, ds ipld.DAGService, a, b ipld.Node) ([]*Change, error) {
94
if len(a.Links()) == 0 && len(b.Links()) == 0 {
95
return []*Change{
96
&Change{
merkledag/utils/diffenum.go
+5
-5
@@ -7,13 +7,13 @@ import (
7
mdag "github.com/ipfs/go-ipfs/merkledag"
8
9
cid "gx/ipfs/QmcZfnkapfECQGcLZaf9B79NRg7cRa9EnZh4LSbkCzwNvY/go-cid"
10
- node "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
10
+ ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
11
)
12
13
// DiffEnumerate fetches every object in the graph pointed to by 'to' that is
14
// not in 'from'. This can be used to more efficiently fetch a graph if you can
15
// guarantee you already have the entirety of 'from'
16
-func DiffEnumerate(ctx context.Context, dserv node.NodeGetter, from, to *cid.Cid) error {
16
+func DiffEnumerate(ctx context.Context, dserv ipld.NodeGetter, from, to *cid.Cid) error {
17
fnd, err := dserv.Get(ctx, from)
18
if err != nil {
19
return fmt.Errorf("get %s: %s", from, err)
@@ -64,9 +64,9 @@ type diffpair struct {
64
65
// getLinkDiff returns a changeset between nodes 'a' and 'b'. Currently does
66
// not log deletions as our usecase doesnt call for this.
67
-func getLinkDiff(a, b node.Node) []diffpair {
68
- ina := make(map[string]*node.Link)
69
- inb := make(map[string]*node.Link)
67
+func getLinkDiff(a, b ipld.Node) []diffpair {
68
+ ina := make(map[string]*ipld.Link)
69
+ inb := make(map[string]*ipld.Link)
70
var aonly []*cid.Cid
71
for _, l := range b.Links() {
72
inb[l.Cid.KeyString()] = l
merkledag/utils/diffenum_test.go
+9
-9
@@ -9,10 +9,10 @@ import (
9
mdtest "github.com/ipfs/go-ipfs/merkledag/test"
10
11
cid "gx/ipfs/QmcZfnkapfECQGcLZaf9B79NRg7cRa9EnZh4LSbkCzwNvY/go-cid"
12
- node "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
12
+ ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
13
)
14
15
-func buildNode(name string, desc map[string]ndesc, out map[string]node.Node) node.Node {
15
+func buildNode(name string, desc map[string]ndesc, out map[string]ipld.Node) ipld.Node {
16
this := desc[name]
17
nd := new(dag.ProtoNode)
18
nd.SetData([]byte(name))
@@ -33,8 +33,8 @@ func buildNode(name string, desc map[string]ndesc, out map[string]node.Node) nod
33
34
type ndesc map[string]string
35
36
-func mkGraph(desc map[string]ndesc) map[string]node.Node {
37
- out := make(map[string]node.Node)
36
+func mkGraph(desc map[string]ndesc) map[string]ipld.Node {
37
+ out := make(map[string]ipld.Node)
38
for name := range desc {
39
if _, ok := out[name]; ok {
40
continue
@@ -154,11 +154,11 @@ func TestDiffEnumBasic(t *testing.T) {
154
}
155
156
type getLogger struct {
157
- ds node.NodeGetter
157
+ ds ipld.NodeGetter
158
log []*cid.Cid
159
}
160
161
-func (gl *getLogger) Get(ctx context.Context, c *cid.Cid) (node.Node, error) {
161
+func (gl *getLogger) Get(ctx context.Context, c *cid.Cid) (ipld.Node, error) {
162
nd, err := gl.ds.Get(ctx, c)
163
if err != nil {
164
return nil, err
@@ -167,8 +167,8 @@ func (gl *getLogger) Get(ctx context.Context, c *cid.Cid) (node.Node, error) {
167
return nd, nil
168
}
169
170
-func (gl *getLogger) GetMany(ctx context.Context, cids []*cid.Cid) <-chan *node.NodeOption {
171
- outCh := make(chan *node.NodeOption, len(cids))
170
+func (gl *getLogger) GetMany(ctx context.Context, cids []*cid.Cid) <-chan *ipld.NodeOption {
171
+ outCh := make(chan *ipld.NodeOption, len(cids))
172
nds := gl.ds.GetMany(ctx, cids)
173
for no := range nds {
174
if no.Err == nil {
@@ -211,7 +211,7 @@ func TestDiffEnumFail(t *testing.T) {
211
}
212
213
err := DiffEnumerate(ctx, lgds, nds["a1"].Cid(), nds["a2"].Cid())
214
- if err != node.ErrNotFound {
214
+ if err != ipld.ErrNotFound {
215
t.Fatal("expected err not found")
216
}
217
merkledag/utils/utils.go
+14
-14
@@ -12,7 +12,7 @@ import (
12
13
ds "gx/ipfs/QmPpegoMqhAEqjncrzArm7KVWAkCm78rqL2DPuNjhPrshg/go-datastore"
14
syncds "gx/ipfs/QmPpegoMqhAEqjncrzArm7KVWAkCm78rqL2DPuNjhPrshg/go-datastore/sync"
15
- node "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
15
+ ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
16
)
17
18
type Editor struct {
@@ -20,15 +20,15 @@ type Editor struct {
20
21
// tmp is a temporary in memory (for now) dagstore for all of the
22
// intermediary nodes to be stored in
23
- tmp node.DAGService
23
+ tmp ipld.DAGService
24
25
// src is the dagstore with *all* of the data on it, it is used to pull
26
// nodes from for modification (nil is a valid value)
27
- src node.DAGService
27
+ src ipld.DAGService
28
}
29
30
// NewMemoryDagService returns a new, thread-safe in-memory DAGService.
31
-func NewMemoryDagService() node.DAGService {
31
+func NewMemoryDagService() ipld.DAGService {
32
// build mem-datastore for editor's intermediary nodes
33
bs := bstore.NewBlockstore(syncds.MutexWrap(ds.NewMapDatastore()))
34
bsrv := bserv.New(bs, offline.Exchange(bs))
@@ -39,7 +39,7 @@ func NewMemoryDagService() node.DAGService {
39
//
40
// * root is the node to be modified
41
// * source is the dagstore to pull nodes from (optional)
42
-func NewDagEditor(root *dag.ProtoNode, source node.DAGService) *Editor {
42
+func NewDagEditor(root *dag.ProtoNode, source ipld.DAGService) *Editor {
43
return &Editor{
44
root: root,
45
tmp: NewMemoryDagService(),
@@ -53,11 +53,11 @@ func (e *Editor) GetNode() *dag.ProtoNode {
53
}
54
55
// GetDagService returns the DAGService used by this editor.
56
-func (e *Editor) GetDagService() node.DAGService {
56
+func (e *Editor) GetDagService() ipld.DAGService {
57
return e.tmp
58
}
59
60
-func addLink(ctx context.Context, ds node.DAGService, root *dag.ProtoNode, childname string, childnd node.Node) (*dag.ProtoNode, error) {
60
+func addLink(ctx context.Context, ds ipld.DAGService, root *dag.ProtoNode, childname string, childnd ipld.Node) (*dag.ProtoNode, error) {
61
if childname == "" {
62
return nil, errors.New("cannot create link with no name")
63
}
@@ -83,7 +83,7 @@ func addLink(ctx context.Context, ds node.DAGService, root *dag.ProtoNode, child
83
return root, nil
84
}
85
86
-func (e *Editor) InsertNodeAtPath(ctx context.Context, pth string, toinsert node.Node, create func() *dag.ProtoNode) error {
86
+func (e *Editor) InsertNodeAtPath(ctx context.Context, pth string, toinsert ipld.Node, create func() *dag.ProtoNode) error {
87
splpath := path.SplitList(pth)
88
nd, err := e.insertNodeAtPath(ctx, e.root, splpath, toinsert, create)
89
if err != nil {
@@ -93,7 +93,7 @@ func (e *Editor) InsertNodeAtPath(ctx context.Context, pth string, toinsert node
93
return nil
94
}
95
96
-func (e *Editor) insertNodeAtPath(ctx context.Context, root *dag.ProtoNode, path []string, toinsert node.Node, create func() *dag.ProtoNode) (*dag.ProtoNode, error) {
96
+func (e *Editor) insertNodeAtPath(ctx context.Context, root *dag.ProtoNode, path []string, toinsert ipld.Node, create func() *dag.ProtoNode) (*dag.ProtoNode, error) {
97
if len(path) == 1 {
98
return addLink(ctx, e.tmp, root, path[0], toinsert)
99
}
@@ -104,7 +104,7 @@ func (e *Editor) insertNodeAtPath(ctx context.Context, root *dag.ProtoNode, path
104
if err == dag.ErrLinkNotFound && create != nil {
105
nd = create()
106
err = nil // no longer an error case
107
- } else if err == node.ErrNotFound {
107
+ } else if err == ipld.ErrNotFound {
108
// try finding it in our source dagstore
109
nd, err = root.GetLinkedProtoNode(ctx, e.src, path[0])
110
}
@@ -165,7 +165,7 @@ func (e *Editor) rmLink(ctx context.Context, root *dag.ProtoNode, path []string)
165
166
// search for node in both tmp dagstore and source dagstore
167
nd, err := root.GetLinkedProtoNode(ctx, e.tmp, path[0])
168
- if err == node.ErrNotFound {
168
+ if err == ipld.ErrNotFound {
169
nd, err = root.GetLinkedProtoNode(ctx, e.src, path[0])
170
}
171
@@ -196,13 +196,13 @@ func (e *Editor) rmLink(ctx context.Context, root *dag.ProtoNode, path []string)
196
197
// Finalize writes the new DAG to the given DAGService and returns the modified
198
// root node.
199
-func (e *Editor) Finalize(ctx context.Context, ds node.DAGService) (*dag.ProtoNode, error) {
199
+func (e *Editor) Finalize(ctx context.Context, ds ipld.DAGService) (*dag.ProtoNode, error) {
200
nd := e.GetNode()
201
err := copyDag(ctx, nd, e.tmp, ds)
202
return nd, err
203
}
204
205
-func copyDag(ctx context.Context, nd node.Node, from, to node.DAGService) error {
205
+func copyDag(ctx context.Context, nd ipld.Node, from, to ipld.DAGService) error {
206
// TODO(#4609): make this batch.
207
err := to.Add(ctx, nd)
208
if err != nil {
@@ -212,7 +212,7 @@ func copyDag(ctx context.Context, nd node.Node, from, to node.DAGService) error
212
for _, lnk := range nd.Links() {
213
child, err := lnk.GetNode(ctx, from)
214
if err != nil {
215
- if err == node.ErrNotFound {
215
+ if err == ipld.ErrNotFound {
216
// not found means we didnt modify it, and it should
217
// already be in the target datastore
218
continue
merkledag/utils/utils_test.go
+2
-2
@@ -9,7 +9,7 @@ import (
9
path "github.com/ipfs/go-ipfs/path"
10
11
cid "gx/ipfs/QmcZfnkapfECQGcLZaf9B79NRg7cRa9EnZh4LSbkCzwNvY/go-cid"
12
- node "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
12
+ ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
13
)
14
15
func TestAddLink(t *testing.T) {
@@ -41,7 +41,7 @@ func TestAddLink(t *testing.T) {
41
}
42
}
43
44
-func assertNodeAtPath(t *testing.T, ds node.DAGService, root *dag.ProtoNode, pth string, exp *cid.Cid) {
44
+func assertNodeAtPath(t *testing.T, ds ipld.DAGService, root *dag.ProtoNode, pth string, exp *cid.Cid) {
45
parts := path.SplitList(pth)
46
cur := root
47
for _, e := range parts {
mfs/dir.go
+12
-12
@@ -16,7 +16,7 @@ import (
16
ufspb "github.com/ipfs/go-ipfs/unixfs/pb"
17
18
cid "gx/ipfs/QmcZfnkapfECQGcLZaf9B79NRg7cRa9EnZh4LSbkCzwNvY/go-cid"
19
- node "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
19
+ ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
20
)
21
22
var ErrNotYetImplemented = errors.New("not yet implemented")
@@ -24,7 +24,7 @@ var ErrInvalidChild = errors.New("invalid child node")
24
var ErrDirExists = errors.New("directory already has entry by that name")
25
26
type Directory struct {
27
- dserv node.DAGService
27
+ dserv ipld.DAGService
28
parent childCloser
29
30
childDirs map[string]*Directory
@@ -44,7 +44,7 @@ type Directory struct {
44
//
45
// You probably don't want to call this directly. Instead, construct a new root
46
// using NewRoot.
47
-func NewDirectory(ctx context.Context, name string, node node.Node, parent childCloser, dserv node.DAGService) (*Directory, error) {
47
+func NewDirectory(ctx context.Context, name string, node ipld.Node, parent childCloser, dserv ipld.DAGService) (*Directory, error) {
48
db, err := uio.NewDirectoryFromNode(dserv, node)
49
if err != nil {
50
return nil, err
@@ -74,7 +74,7 @@ func (d *Directory) SetPrefix(prefix *cid.Prefix) {
74
75
// closeChild updates the child by the given name to the dag node 'nd'
76
// and changes its own dag node
77
-func (d *Directory) closeChild(name string, nd node.Node, sync bool) error {
77
+func (d *Directory) closeChild(name string, nd ipld.Node, sync bool) error {
78
mynd, err := d.closeChildUpdate(name, nd, sync)
79
if err != nil {
80
return err
@@ -87,7 +87,7 @@ func (d *Directory) closeChild(name string, nd node.Node, sync bool) error {
87
}
88
89
// closeChildUpdate is the portion of closeChild that needs to be locked around
90
-func (d *Directory) closeChildUpdate(name string, nd node.Node, sync bool) (*dag.ProtoNode, error) {
90
+func (d *Directory) closeChildUpdate(name string, nd ipld.Node, sync bool) (*dag.ProtoNode, error) {
91
d.lock.Lock()
92
defer d.lock.Unlock()
93
@@ -121,7 +121,7 @@ func (d *Directory) flushCurrentNode() (*dag.ProtoNode, error) {
121
return pbnd.Copy().(*dag.ProtoNode), nil
122
}
123
124
-func (d *Directory) updateChild(name string, nd node.Node) error {
124
+func (d *Directory) updateChild(name string, nd ipld.Node) error {
125
err := d.dirbuilder.AddChild(d.ctx, name, nd)
126
if err != nil {
127
return err
@@ -148,7 +148,7 @@ func (d *Directory) childNode(name string) (FSNode, error) {
148
}
149
150
// cacheNode caches a node into d.childDirs or d.files and returns the FSNode.
151
-func (d *Directory) cacheNode(name string, nd node.Node) (FSNode, error) {
151
+func (d *Directory) cacheNode(name string, nd ipld.Node) (FSNode, error) {
152
switch nd := nd.(type) {
153
case *dag.ProtoNode:
154
i, err := ft.FromBytes(nd.Data())
@@ -205,7 +205,7 @@ func (d *Directory) Uncache(name string) {
205
206
// childFromDag searches through this directories dag node for a child link
207
// with the given name
208
-func (d *Directory) childFromDag(name string) (node.Node, error) {
208
+func (d *Directory) childFromDag(name string) (ipld.Node, error) {
209
return d.dirbuilder.Find(d.ctx, name)
210
}
211
@@ -237,7 +237,7 @@ func (d *Directory) ListNames(ctx context.Context) ([]string, error) {
237
defer d.lock.Unlock()
238
239
var out []string
240
- err := d.dirbuilder.ForEachLink(ctx, func(l *node.Link) error {
240
+ err := d.dirbuilder.ForEachLink(ctx, func(l *ipld.Link) error {
241
out = append(out, l.Name)
242
return nil
243
})
@@ -262,7 +262,7 @@ func (d *Directory) List(ctx context.Context) ([]NodeListing, error) {
262
func (d *Directory) ForEachEntry(ctx context.Context, f func(NodeListing) error) error {
263
d.lock.Lock()
264
defer d.lock.Unlock()
265
- return d.dirbuilder.ForEachLink(ctx, func(l *node.Link) error {
265
+ return d.dirbuilder.ForEachLink(ctx, func(l *ipld.Link) error {
266
c, err := d.childUnsync(l.Name)
267
if err != nil {
268
return err
@@ -349,7 +349,7 @@ func (d *Directory) Flush() error {
349
}
350
351
// AddChild adds the node 'nd' under this directory giving it the name 'name'
352
-func (d *Directory) AddChild(name string, nd node.Node) error {
352
+func (d *Directory) AddChild(name string, nd ipld.Node) error {
353
d.lock.Lock()
354
defer d.lock.Unlock()
355
@@ -410,7 +410,7 @@ func (d *Directory) Path() string {
410
return out
411
}
412
413
-func (d *Directory) GetNode() (node.Node, error) {
413
+func (d *Directory) GetNode() (ipld.Node, error) {
414
d.lock.Lock()
415
defer d.lock.Unlock()
416
mfs/file.go
+5
-5
@@ -10,7 +10,7 @@ import (
10
ft "github.com/ipfs/go-ipfs/unixfs"
11
mod "github.com/ipfs/go-ipfs/unixfs/mod"
12
13
- node "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
13
+ ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
14
)
15
16
type File struct {
@@ -20,8 +20,8 @@ type File struct {
20
21
desclock sync.RWMutex
22
23
- dserv node.DAGService
24
- node node.Node
23
+ dserv ipld.DAGService
24
+ node ipld.Node
25
nodelk sync.Mutex
26
27
RawLeaves bool
@@ -29,7 +29,7 @@ type File struct {
29
30
// NewFile returns a NewFile object with the given parameters. If the
31
// Cid version is non-zero RawLeaves will be enabled.
32
-func NewFile(name string, node node.Node, parent childCloser, dserv node.DAGService) (*File, error) {
32
+func NewFile(name string, node ipld.Node, parent childCloser, dserv ipld.DAGService) (*File, error) {
33
fi := &File{
34
dserv: dserv,
35
parent: parent,
@@ -115,7 +115,7 @@ func (fi *File) Size() (int64, error) {
115
}
116
117
// GetNode returns the dag node associated with this file
118
-func (fi *File) GetNode() (node.Node, error) {
118
+func (fi *File) GetNode() (ipld.Node, error) {
119
fi.nodelk.Lock()
120
defer fi.nodelk.Unlock()
121
return fi.node, nil
mfs/mfs_test.go
+8
-8
@@ -28,26 +28,26 @@ import (
28
ds "gx/ipfs/QmPpegoMqhAEqjncrzArm7KVWAkCm78rqL2DPuNjhPrshg/go-datastore"
29
dssync "gx/ipfs/QmPpegoMqhAEqjncrzArm7KVWAkCm78rqL2DPuNjhPrshg/go-datastore/sync"
30
cid "gx/ipfs/QmcZfnkapfECQGcLZaf9B79NRg7cRa9EnZh4LSbkCzwNvY/go-cid"
31
- node "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
31
+ ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
32
)
33
34
func emptyDirNode() *dag.ProtoNode {
35
return dag.NodeWithData(ft.FolderPBData())
36
}
37
38
-func getDagserv(t *testing.T) node.DAGService {
38
+func getDagserv(t *testing.T) ipld.DAGService {
39
db := dssync.MutexWrap(ds.NewMapDatastore())
40
bs := bstore.NewBlockstore(db)
41
blockserv := bserv.New(bs, offline.Exchange(bs))
42
return dag.NewDAGService(blockserv)
43
}
44
45
-func getRandFile(t *testing.T, ds node.DAGService, size int64) node.Node {
45
+func getRandFile(t *testing.T, ds ipld.DAGService, size int64) ipld.Node {
46
r := io.LimitReader(u.NewTimeSeededRand(), size)
47
return fileNodeFromReader(t, ds, r)
48
}
49
50
-func fileNodeFromReader(t *testing.T, ds node.DAGService, r io.Reader) node.Node {
50
+func fileNodeFromReader(t *testing.T, ds ipld.DAGService, r io.Reader) ipld.Node {
51
nd, err := importer.BuildDagFromReader(ds, chunk.DefaultSplitter(r))
52
if err != nil {
53
t.Fatal(err)
@@ -128,7 +128,7 @@ func compStrArrs(a, b []string) bool {
128
return true
129
}
130
131
-func assertFileAtPath(ds node.DAGService, root *Directory, expn node.Node, pth string) error {
131
+func assertFileAtPath(ds ipld.DAGService, root *Directory, expn ipld.Node, pth string) error {
132
exp, ok := expn.(*dag.ProtoNode)
133
if !ok {
134
return dag.ErrNotProtobuf
@@ -182,7 +182,7 @@ func assertFileAtPath(ds node.DAGService, root *Directory, expn node.Node, pth s
182
return nil
183
}
184
185
-func catNode(ds node.DAGService, nd *dag.ProtoNode) ([]byte, error) {
185
+func catNode(ds ipld.DAGService, nd *dag.ProtoNode) ([]byte, error) {
186
r, err := uio.NewDagReader(context.TODO(), nd, ds)
187
if err != nil {
188
return nil, err
@@ -192,7 +192,7 @@ func catNode(ds node.DAGService, nd *dag.ProtoNode) ([]byte, error) {
192
return ioutil.ReadAll(r)
193
}
194
195
-func setupRoot(ctx context.Context, t *testing.T) (node.DAGService, *Root) {
195
+func setupRoot(ctx context.Context, t *testing.T) (ipld.DAGService, *Root) {
196
ds := getDagserv(t)
197
198
root := emptyDirNode()
@@ -300,7 +300,7 @@ func TestDirectoryLoadFromDag(t *testing.T) {
300
dirhash := dir.Cid()
301
302
top := emptyDirNode()
303
- top.SetLinks([]*node.Link{
303
+ top.SetLinks([]*ipld.Link{
304
{
305
Name: "a",
306
Cid: fihash,
mfs/ops.go
+2
-2
@@ -10,7 +10,7 @@ import (
10
path "github.com/ipfs/go-ipfs/path"
11
12
cid "gx/ipfs/QmcZfnkapfECQGcLZaf9B79NRg7cRa9EnZh4LSbkCzwNvY/go-cid"
13
- node "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
13
+ ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
14
)
15
16
// Mv moves the file or directory at 'src' to 'dst'
@@ -84,7 +84,7 @@ func lookupDir(r *Root, path string) (*Directory, error) {
84
}
85
86
// PutNode inserts 'nd' at 'path' in the given mfs
87
-func PutNode(r *Root, path string, nd node.Node) error {
87
+func PutNode(r *Root, path string, nd ipld.Node) error {
88
dirp, filename := gopath.Split(path)
89
if filename == "" {
90
return fmt.Errorf("cannot create file with empty name")
mfs/system.go
+6
-6
@@ -21,7 +21,7 @@ import (
21
22
logging "gx/ipfs/QmSpJByNKFX1sCsHBEp3R73FL4NF6FnQTEGyNAXHm2GS52/go-log"
23
cid "gx/ipfs/QmcZfnkapfECQGcLZaf9B79NRg7cRa9EnZh4LSbkCzwNvY/go-cid"
24
- node "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
24
+ ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
25
)
26
27
var ErrNotExist = errors.New("no such rootfs")
@@ -31,7 +31,7 @@ var log = logging.Logger("mfs")
31
var ErrIsDirectory = errors.New("error: is a directory")
32
33
type childCloser interface {
34
- closeChild(string, node.Node, bool) error
34
+ closeChild(string, ipld.Node, bool) error
35
}
36
37
type NodeType int
@@ -43,7 +43,7 @@ const (
43
44
// FSNode represents any node (directory, root, or file) in the mfs filesystem.
45
type FSNode interface {
46
- GetNode() (node.Node, error)
46
+ GetNode() (ipld.Node, error)
47
Flush() error
48
Type() NodeType
49
}
@@ -58,7 +58,7 @@ type Root struct {
58
59
repub *Republisher
60
61
- dserv node.DAGService
61
+ dserv ipld.DAGService
62
63
Type string
64
}
@@ -67,7 +67,7 @@ type Root struct {
67
type PubFunc func(context.Context, *cid.Cid) error
68
69
// NewRoot creates a new Root and starts up a republisher routine for it.
70
-func NewRoot(parent context.Context, ds node.DAGService, node *dag.ProtoNode, pf PubFunc) (*Root, error) {
70
+func NewRoot(parent context.Context, ds ipld.DAGService, node *dag.ProtoNode, pf PubFunc) (*Root, error) {
71
72
var repub *Republisher
73
if pf != nil {
@@ -159,7 +159,7 @@ func (kr *Root) FlushMemFree(ctx context.Context) error {
159
160
// closeChild implements the childCloser interface, and signals to the publisher that
161
// there are changes ready to be published.
162
-func (kr *Root) closeChild(name string, nd node.Node, sync bool) error {
162
+func (kr *Root) closeChild(name string, nd ipld.Node, sync bool) error {
163
err := kr.dserv.Add(context.TODO(), nd)
164
if err != nil {
165
return err
path/resolver.go
+11
-11
@@ -11,7 +11,7 @@ import (
11
12
logging "gx/ipfs/QmSpJByNKFX1sCsHBEp3R73FL4NF6FnQTEGyNAXHm2GS52/go-log"
13
cid "gx/ipfs/QmcZfnkapfECQGcLZaf9B79NRg7cRa9EnZh4LSbkCzwNvY/go-cid"
14
- node "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
14
+ ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
15
)
16
17
var log = logging.Logger("path")
@@ -35,13 +35,13 @@ func (e ErrNoLink) Error() string {
35
// TODO: now that this is more modular, try to unify this code with the
36
// the resolvers in namesys
37
type Resolver struct {
38
- DAG node.DAGService
38
+ DAG ipld.DAGService
39
40
- ResolveOnce func(ctx context.Context, ds node.DAGService, nd node.Node, names []string) (*node.Link, []string, error)
40
+ ResolveOnce func(ctx context.Context, ds ipld.DAGService, nd ipld.Node, names []string) (*ipld.Link, []string, error)
41
}
42
43
// NewBasicResolver constructs a new basic resolver.
44
-func NewBasicResolver(ds node.DAGService) *Resolver {
44
+func NewBasicResolver(ds ipld.DAGService) *Resolver {
45
return &Resolver{
46
DAG: ds,
47
ResolveOnce: ResolveSingle,
@@ -74,7 +74,7 @@ func SplitAbsPath(fpath Path) (*cid.Cid, []string, error) {
74
return c, parts[1:], nil
75
}
76
77
-func (r *Resolver) ResolveToLastNode(ctx context.Context, fpath Path) (node.Node, []string, error) {
77
+func (r *Resolver) ResolveToLastNode(ctx context.Context, fpath Path) (ipld.Node, []string, error) {
78
c, p, err := SplitAbsPath(fpath)
79
if err != nil {
80
return nil, nil, err
@@ -92,7 +92,7 @@ func (r *Resolver) ResolveToLastNode(ctx context.Context, fpath Path) (node.Node
92
}
93
94
switch val := val.(type) {
95
- case *node.Link:
95
+ case *ipld.Link:
96
next, err := val.GetNode(ctx, r.DAG)
97
if err != nil {
98
return nil, nil, err
@@ -109,7 +109,7 @@ func (r *Resolver) ResolveToLastNode(ctx context.Context, fpath Path) (node.Node
109
110
// ResolvePath fetches the node for given path. It returns the last item
111
// returned by ResolvePathComponents.
112
-func (s *Resolver) ResolvePath(ctx context.Context, fpath Path) (node.Node, error) {
112
+func (s *Resolver) ResolvePath(ctx context.Context, fpath Path) (ipld.Node, error) {
113
// validate path
114
if err := fpath.IsValid(); err != nil {
115
return nil, err
@@ -124,14 +124,14 @@ func (s *Resolver) ResolvePath(ctx context.Context, fpath Path) (node.Node, erro
124
125
// ResolveSingle simply resolves one hop of a path through a graph with no
126
// extra context (does not opaquely resolve through sharded nodes)
127
-func ResolveSingle(ctx context.Context, ds node.DAGService, nd node.Node, names []string) (*node.Link, []string, error) {
127
+func ResolveSingle(ctx context.Context, ds ipld.DAGService, nd ipld.Node, names []string) (*ipld.Link, []string, error) {
128
return nd.ResolveLink(names)
129
}
130
131
// ResolvePathComponents fetches the nodes for each segment of the given path.
132
// It uses the first path component as a hash (key) of the first node, then
133
// resolves all other components walking the links, with ResolveLinks.
134
-func (s *Resolver) ResolvePathComponents(ctx context.Context, fpath Path) ([]node.Node, error) {
134
+func (s *Resolver) ResolvePathComponents(ctx context.Context, fpath Path) ([]ipld.Node, error) {
135
evt := log.EventBegin(ctx, "resolvePathComponents", logging.LoggableMap{"fpath": fpath})
136
defer evt.Done()
137
@@ -158,11 +158,11 @@ func (s *Resolver) ResolvePathComponents(ctx context.Context, fpath Path) ([]nod
158
//
159
// ResolveLinks(nd, []string{"foo", "bar", "baz"})
160
// would retrieve "baz" in ("bar" in ("foo" in nd.Links).Links).Links
161
-func (s *Resolver) ResolveLinks(ctx context.Context, ndd node.Node, names []string) ([]node.Node, error) {
161
+func (s *Resolver) ResolveLinks(ctx context.Context, ndd ipld.Node, names []string) ([]ipld.Node, error) {
162
163
evt := log.EventBegin(ctx, "resolveLinks", logging.LoggableMap{"names": names})
164
defer evt.Done()
165
- result := make([]node.Node, 0, len(names)+1)
165
+ result := make([]ipld.Node, 0, len(names)+1)
166
result = append(result, ndd)
167
nd := ndd // dup arg workaround
168
path/resolver_test.go
+2
-2
@@ -10,7 +10,7 @@ import (
10
path "github.com/ipfs/go-ipfs/path"
11
12
util "gx/ipfs/QmNiJuT8Ja3hMVpBHXv3Q6dwmperaQ6JjLtpMQgMCD7xvx/go-ipfs-util"
13
- node "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
13
+ ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
14
)
15
16
func randNode() *merkledag.ProtoNode {
@@ -38,7 +38,7 @@ func TestRecurivePathResolution(t *testing.T) {
38
t.Fatal(err)
39
}
40
41
- for _, n := range []node.Node{a, b, c} {
41
+ for _, n := range []ipld.Node{a, b, c} {
42
err = dagService.Add(ctx, n)
43
if err != nil {
44
t.Fatal(err)
pin/gc/gc.go
+7
-7
@@ -13,7 +13,7 @@ import (
13
14
logging "gx/ipfs/QmSpJByNKFX1sCsHBEp3R73FL4NF6FnQTEGyNAXHm2GS52/go-log"
15
cid "gx/ipfs/QmcZfnkapfECQGcLZaf9B79NRg7cRa9EnZh4LSbkCzwNvY/go-cid"
16
- node "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
16
+ ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
17
)
18
19
var log = logging.Logger("gc")
@@ -128,13 +128,13 @@ func Descendants(ctx context.Context, getLinks dag.GetLinks, set *cid.Set, roots
128
129
// ColoredSet computes the set of nodes in the graph that are pinned by the
130
// pins in the given pinner.
131
-func ColoredSet(ctx context.Context, pn pin.Pinner, ng node.NodeGetter, bestEffortRoots []*cid.Cid, output chan<- Result) (*cid.Set, error) {
131
+func ColoredSet(ctx context.Context, pn pin.Pinner, ng ipld.NodeGetter, bestEffortRoots []*cid.Cid, output chan<- Result) (*cid.Set, error) {
132
// KeySet currently implemented in memory, in the future, may be bloom filter or
133
// disk backed to conserve memory.
134
errors := false
135
gcs := cid.NewSet()
136
- getLinks := func(ctx context.Context, cid *cid.Cid) ([]*node.Link, error) {
137
- links, err := node.GetLinks(ctx, ng, cid)
136
+ getLinks := func(ctx context.Context, cid *cid.Cid) ([]*ipld.Link, error) {
137
+ links, err := ipld.GetLinks(ctx, ng, cid)
138
if err != nil {
139
errors = true
140
output <- Result{Error: &CannotFetchLinksError{cid, err}}
@@ -147,9 +147,9 @@ func ColoredSet(ctx context.Context, pn pin.Pinner, ng node.NodeGetter, bestEffo
147
output <- Result{Error: err}
148
}
149
150
- bestEffortGetLinks := func(ctx context.Context, cid *cid.Cid) ([]*node.Link, error) {
151
- links, err := node.GetLinks(ctx, ng, cid)
152
- if err != nil && err != node.ErrNotFound {
150
+ bestEffortGetLinks := func(ctx context.Context, cid *cid.Cid) ([]*ipld.Link, error) {
151
+ links, err := ipld.GetLinks(ctx, ng, cid)
152
+ if err != nil && err != ipld.ErrNotFound {
153
errors = true
154
output <- Result{Error: &CannotFetchLinksError{cid, err}}
155
}
pin/pin.go
+10
-10
@@ -15,7 +15,7 @@ import (
15
ds "gx/ipfs/QmPpegoMqhAEqjncrzArm7KVWAkCm78rqL2DPuNjhPrshg/go-datastore"
16
logging "gx/ipfs/QmSpJByNKFX1sCsHBEp3R73FL4NF6FnQTEGyNAXHm2GS52/go-log"
17
cid "gx/ipfs/QmcZfnkapfECQGcLZaf9B79NRg7cRa9EnZh4LSbkCzwNvY/go-cid"
18
- node "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
18
+ ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
19
)
20
21
var log = logging.Logger("pin")
@@ -102,7 +102,7 @@ type Pinner interface {
102
IsPinnedWithType(*cid.Cid, PinMode) (string, bool, error)
103
104
// Pin the given node, optionally recursively.
105
- Pin(ctx context.Context, node node.Node, recursive bool) error
105
+ Pin(ctx context.Context, node ipld.Node, recursive bool) error
106
107
// Unpin the given cid. If recursive is true, removes either a recursive or
108
// a direct pin. If recursive is false, only removes a direct pin.
@@ -178,13 +178,13 @@ type pinner struct {
178
// Track the keys used for storing the pinning state, so gc does
179
// not delete them.
180
internalPin *cid.Set
181
- dserv node.DAGService
182
- internal node.DAGService // dagservice used to store internal objects
181
+ dserv ipld.DAGService
182
+ internal ipld.DAGService // dagservice used to store internal objects
183
dstore ds.Datastore
184
}
185
186
// NewPinner creates a new pinner using the given datastore as a backend
187
-func NewPinner(dstore ds.Datastore, serv, internal node.DAGService) Pinner {
187
+func NewPinner(dstore ds.Datastore, serv, internal ipld.DAGService) Pinner {
188
189
rcset := cid.NewSet()
190
dirset := cid.NewSet()
@@ -200,7 +200,7 @@ func NewPinner(dstore ds.Datastore, serv, internal node.DAGService) Pinner {
200
}
201
202
// Pin the given node, optionally recursive
203
-func (p *pinner) Pin(ctx context.Context, node node.Node, recurse bool) error {
203
+func (p *pinner) Pin(ctx context.Context, node ipld.Node, recurse bool) error {
204
p.lock.Lock()
205
defer p.lock.Unlock()
206
err := p.dserv.Add(ctx, node)
@@ -358,7 +358,7 @@ func (p *pinner) CheckIfPinned(cids ...*cid.Cid) ([]Pinned, error) {
358
// Now walk all recursive pins to check for indirect pins
359
var checkChildren func(*cid.Cid, *cid.Cid) error
360
checkChildren = func(rk, parentKey *cid.Cid) error {
361
- links, err := node.GetLinks(context.TODO(), p.dserv, parentKey)
361
+ links, err := ipld.GetLinks(context.TODO(), p.dserv, parentKey)
362
if err != nil {
363
return err
364
}
@@ -427,7 +427,7 @@ func cidSetWithValues(cids []*cid.Cid) *cid.Set {
427
}
428
429
// LoadPinner loads a pinner and its keysets from the given datastore
430
-func LoadPinner(d ds.Datastore, dserv, internal node.DAGService) (Pinner, error) {
430
+func LoadPinner(d ds.Datastore, dserv, internal ipld.DAGService) (Pinner, error) {
431
p := new(pinner)
432
433
rootKeyI, err := d.Get(pinDatastoreKey)
@@ -597,8 +597,8 @@ func (p *pinner) PinWithMode(c *cid.Cid, mode PinMode) {
597
598
// hasChild recursively looks for a Cid among the children of a root Cid.
599
// The visit function can be used to shortcut already-visited branches.
600
-func hasChild(ng node.NodeGetter, root *cid.Cid, child *cid.Cid, visit func(*cid.Cid) bool) (bool, error) {
601
- links, err := node.GetLinks(context.TODO(), ng, root)
600
+func hasChild(ng ipld.NodeGetter, root *cid.Cid, child *cid.Cid, visit func(*cid.Cid) bool) (bool, error) {
601
+ links, err := ipld.GetLinks(context.TODO(), ng, root)
602
if err != nil {
603
return false, err
604
}
pin/set.go
+12
-12
@@ -14,7 +14,7 @@ import (
14
15
"gx/ipfs/QmZ4Qi3GaRbjcx28Sme5eMH7RQjGkt8wHxt2a65oLaeFEV/gogo-protobuf/proto"
16
cid "gx/ipfs/QmcZfnkapfECQGcLZaf9B79NRg7cRa9EnZh4LSbkCzwNvY/go-cid"
17
- node "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
17
+ ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
18
)
19
20
const (
@@ -39,7 +39,7 @@ type itemIterator func() (c *cid.Cid, ok bool)
39
type keyObserver func(*cid.Cid)
40
41
type sortByHash struct {
42
- links []*node.Link
42
+ links []*ipld.Link
43
}
44
45
func (s sortByHash) Len() int {
@@ -54,10 +54,10 @@ func (s sortByHash) Swap(a, b int) {
54
s.links[a], s.links[b] = s.links[b], s.links[a]
55
}
56
57
-func storeItems(ctx context.Context, dag node.DAGService, estimatedLen uint64, depth uint32, iter itemIterator, internalKeys keyObserver) (*merkledag.ProtoNode, error) {
58
- links := make([]*node.Link, 0, defaultFanout+maxItems)
57
+func storeItems(ctx context.Context, dag ipld.DAGService, estimatedLen uint64, depth uint32, iter itemIterator, internalKeys keyObserver) (*merkledag.ProtoNode, error) {
58
+ links := make([]*ipld.Link, 0, defaultFanout+maxItems)
59
for i := 0; i < defaultFanout; i++ {
60
- links = append(links, &node.Link{Cid: emptyKey})
60
+ links = append(links, &ipld.Link{Cid: emptyKey})
61
}
62
63
// add emptyKey to our set of internal pinset objects
@@ -85,7 +85,7 @@ func storeItems(ctx context.Context, dag node.DAGService, estimatedLen uint64, d
85
break
86
}
87
88
- links = append(links, &node.Link{Cid: k})
88
+ links = append(links, &ipld.Link{Cid: k})
89
}
90
91
n.SetLinks(links)
@@ -148,7 +148,7 @@ func storeItems(ctx context.Context, dag node.DAGService, estimatedLen uint64, d
148
internalKeys(childKey)
149
150
// overwrite the 'empty key' in the existing links array
151
- n.Links()[h] = &node.Link{
151
+ n.Links()[h] = &ipld.Link{
152
Cid: childKey,
153
Size: size,
154
}
@@ -201,9 +201,9 @@ func writeHdr(n *merkledag.ProtoNode, hdr *pb.Set) error {
201
return nil
202
}
203
204
-type walkerFunc func(idx int, link *node.Link) error
204
+type walkerFunc func(idx int, link *ipld.Link) error
205
206
-func walkItems(ctx context.Context, dag node.DAGService, n *merkledag.ProtoNode, fn walkerFunc, children keyObserver) error {
206
+func walkItems(ctx context.Context, dag ipld.DAGService, n *merkledag.ProtoNode, fn walkerFunc, children keyObserver) error {
207
hdr, err := readHdr(n)
208
if err != nil {
209
return err
@@ -238,7 +238,7 @@ func walkItems(ctx context.Context, dag node.DAGService, n *merkledag.ProtoNode,
238
return nil
239
}
240
241
-func loadSet(ctx context.Context, dag node.DAGService, root *merkledag.ProtoNode, name string, internalKeys keyObserver) ([]*cid.Cid, error) {
241
+func loadSet(ctx context.Context, dag ipld.DAGService, root *merkledag.ProtoNode, name string, internalKeys keyObserver) ([]*cid.Cid, error) {
242
l, err := root.GetNodeLink(name)
243
if err != nil {
244
return nil, err
@@ -258,7 +258,7 @@ func loadSet(ctx context.Context, dag node.DAGService, root *merkledag.ProtoNode
258
}
259
260
var res []*cid.Cid
261
- walk := func(idx int, link *node.Link) error {
261
+ walk := func(idx int, link *ipld.Link) error {
262
res = append(res, link.Cid)
263
return nil
264
}
@@ -281,7 +281,7 @@ func getCidListIterator(cids []*cid.Cid) itemIterator {
281
}
282
}
283
284
-func storeSet(ctx context.Context, dag node.DAGService, cids []*cid.Cid, internalKeys keyObserver) (*merkledag.ProtoNode, error) {
284
+func storeSet(ctx context.Context, dag ipld.DAGService, cids []*cid.Cid, internalKeys keyObserver) (*merkledag.ProtoNode, error) {
285
iter := getCidListIterator(cids)
286
287
n, err := storeItems(ctx, dag, uint64(len(cids)), 0, iter, internalKeys)
plugin/ipld.go
+2
-2
@@ -3,7 +3,7 @@ package plugin
3
import (
4
"github.com/ipfs/go-ipfs/core/coredag"
5
6
- node "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
6
+ ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
7
)
8
9
// PluginIPLD is an interface that can be implemented to add handlers for
@@ -11,6 +11,6 @@ import (
11
type PluginIPLD interface {
12
Plugin
13
14
- RegisterBlockDecoders(dec node.BlockDecoder) error
14
+ RegisterBlockDecoders(dec ipld.BlockDecoder) error
15
RegisterInputEncParsers(iec coredag.InputEncParsers) error
16
}
plugin/loader/initializer.go
+2
-2
@@ -4,7 +4,7 @@ import (
4
"github.com/ipfs/go-ipfs/core/coredag"
5
"github.com/ipfs/go-ipfs/plugin"
6
7
- format "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
7
+ ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
8
)
9
10
func initialize(plugins []plugin.Plugin) error {
@@ -34,7 +34,7 @@ func runIPLDPlugin(pl plugin.Plugin) error {
34
return nil
35
}
36
37
- err := ipldpl.RegisterBlockDecoders(format.DefaultBlockDecoder)
37
+ err := ipldpl.RegisterBlockDecoders(ipld.DefaultBlockDecoder)
38
if err != nil {
39
return err
40
}
tar/format.go
+5
-5
@@ -16,7 +16,7 @@ import (
16
uio "github.com/ipfs/go-ipfs/unixfs/io"
17
18
logging "gx/ipfs/QmSpJByNKFX1sCsHBEp3R73FL4NF6FnQTEGyNAXHm2GS52/go-log"
19
- node "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
19
+ ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
20
)
21
22
var log = logging.Logger("tarfmt")
@@ -36,7 +36,7 @@ func marshalHeader(h *tar.Header) ([]byte, error) {
36
37
// ImportTar imports a tar file into the given DAGService and returns the root
38
// node.
39
-func ImportTar(ctx context.Context, r io.Reader, ds node.DAGService) (*dag.ProtoNode, error) {
39
+func ImportTar(ctx context.Context, r io.Reader, ds ipld.DAGService) (*dag.ProtoNode, error) {
40
tr := tar.NewReader(r)
41
42
root := new(dag.ProtoNode)
@@ -101,8 +101,8 @@ func escapePath(pth string) string {
101
}
102
103
type tarReader struct {
104
- links []*node.Link
105
- ds node.DAGService
104
+ links []*ipld.Link
105
+ ds ipld.DAGService
106
107
childRead *tarReader
108
hdrBuf *bytes.Reader
@@ -198,7 +198,7 @@ func (tr *tarReader) Read(b []byte) (int, error) {
198
199
// ExportTar exports the passed DAG as a tar file. This function is the inverse
200
// of ImportTar.
201
-func ExportTar(ctx context.Context, root *dag.ProtoNode, ds node.DAGService) (io.Reader, error) {
201
+func ExportTar(ctx context.Context, root *dag.ProtoNode, ds ipld.DAGService) (io.Reader, error) {
202
if string(root.Data()) != "ipfs/tar" {
203
return nil, errors.New("not an IPFS tarchive")
204
}
thirdparty/posinfo/posinfo.go
+2
-2
@@ -3,7 +3,7 @@ package posinfo
3
import (
4
"os"
5
6
- node "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
6
+ ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
7
)
8
9
type PosInfo struct {
@@ -13,6 +13,6 @@ type PosInfo struct {
13
}
14
15
type FilestoreNode struct {
16
- node.Node
16
+ ipld.Node
17
PosInfo *PosInfo
18
}
unixfs/archive/archive.go
+2
-2
@@ -10,7 +10,7 @@ import (
10
tar "github.com/ipfs/go-ipfs/unixfs/archive/tar"
11
uio "github.com/ipfs/go-ipfs/unixfs/io"
12
13
- node "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
13
+ ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
14
)
15
16
// DefaultBufSize is the buffer size for gets. for now, 1MB, which is ~4 blocks.
@@ -30,7 +30,7 @@ func (i *identityWriteCloser) Close() error {
30
}
31
32
// DagArchive is equivalent to `ipfs getdag $hash | maybe_tar | maybe_gzip`
33
-func DagArchive(ctx context.Context, nd node.Node, name string, dag node.DAGService, archive bool, compression int) (io.Reader, error) {
33
+func DagArchive(ctx context.Context, nd ipld.Node, name string, dag ipld.DAGService, archive bool, compression int) (io.Reader, error) {
34
35
_, filename := path.Split(name)
36
unixfs/archive/tar/writer.go
+5
-5
@@ -14,21 +14,21 @@ import (
14
upb "github.com/ipfs/go-ipfs/unixfs/pb"
15
16
proto "gx/ipfs/QmZ4Qi3GaRbjcx28Sme5eMH7RQjGkt8wHxt2a65oLaeFEV/gogo-protobuf/proto"
17
- node "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
17
+ ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
18
)
19
20
// Writer is a utility structure that helps to write
21
// unixfs merkledag nodes as a tar archive format.
22
// It wraps any io.Writer.
23
type Writer struct {
24
- Dag node.DAGService
24
+ Dag ipld.DAGService
25
TarW *tar.Writer
26
27
ctx context.Context
28
}
29
30
// NewWriter wraps given io.Writer.
31
-func NewWriter(ctx context.Context, dag node.DAGService, archive bool, compression int, w io.Writer) (*Writer, error) {
31
+func NewWriter(ctx context.Context, dag ipld.DAGService, archive bool, compression int, w io.Writer) (*Writer, error) {
32
return &Writer{
33
Dag: dag,
34
TarW: tar.NewWriter(w),
@@ -41,7 +41,7 @@ func (w *Writer) writeDir(nd *mdag.ProtoNode, fpath string) error {
41
return err
42
}
43
44
- for i, ng := range node.GetDAG(w.ctx, w.Dag, nd) {
44
+ for i, ng := range ipld.GetDAG(w.ctx, w.Dag, nd) {
45
child, err := ng.Get(w.ctx)
46
if err != nil {
47
return err
@@ -69,7 +69,7 @@ func (w *Writer) writeFile(nd *mdag.ProtoNode, pb *upb.Data, fpath string) error
69
return nil
70
}
71
72
-func (w *Writer) WriteNode(nd node.Node, fpath string) error {
72
+func (w *Writer) WriteNode(nd ipld.Node, fpath string) error {
73
switch nd := nd.(type) {
74
case *mdag.ProtoNode:
75
pb := new(upb.Data)
unixfs/hamt/hamt.go
+22
-22
@@ -33,7 +33,7 @@ import (
33
34
proto "gx/ipfs/QmZ4Qi3GaRbjcx28Sme5eMH7RQjGkt8wHxt2a65oLaeFEV/gogo-protobuf/proto"
35
cid "gx/ipfs/QmcZfnkapfECQGcLZaf9B79NRg7cRa9EnZh4LSbkCzwNvY/go-cid"
36
- node "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
36
+ ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
37
"gx/ipfs/QmfJHywXQu98UeZtGJBQrPAR6AtmDjjbe3qjTo9piXHPnx/murmur3"
38
)
39
@@ -57,17 +57,17 @@ type HamtShard struct {
57
prefixPadStr string
58
maxpadlen int
59
60
- dserv node.DAGService
60
+ dserv ipld.DAGService
61
}
62
63
// child can either be another shard, or a leaf node value
64
type child interface {
65
- Link() (*node.Link, error)
65
+ Link() (*ipld.Link, error)
66
Label() string
67
}
68
69
// NewHamtShard creates a new, empty HAMT shard with the given size.
70
-func NewHamtShard(dserv node.DAGService, size int) (*HamtShard, error) {
70
+func NewHamtShard(dserv ipld.DAGService, size int) (*HamtShard, error) {
71
ds, err := makeHamtShard(dserv, size)
72
if err != nil {
73
return nil, err
@@ -79,7 +79,7 @@ func NewHamtShard(dserv node.DAGService, size int) (*HamtShard, error) {
79
return ds, nil
80
}
81
82
-func makeHamtShard(ds node.DAGService, size int) (*HamtShard, error) {
82
+func makeHamtShard(ds ipld.DAGService, size int) (*HamtShard, error) {
83
lg2s := int(math.Log2(float64(size)))
84
if 1<<uint(lg2s) != size {
85
return nil, fmt.Errorf("hamt size should be a power of two")
@@ -95,7 +95,7 @@ func makeHamtShard(ds node.DAGService, size int) (*HamtShard, error) {
95
}
96
97
// NewHamtFromDag creates new a HAMT shard from the given DAG.
98
-func NewHamtFromDag(dserv node.DAGService, nd node.Node) (*HamtShard, error) {
98
+func NewHamtFromDag(dserv ipld.DAGService, nd ipld.Node) (*HamtShard, error) {
99
pbnd, ok := nd.(*dag.ProtoNode)
100
if !ok {
101
return nil, dag.ErrLinkNotFound
@@ -139,7 +139,7 @@ func (ds *HamtShard) Prefix() *cid.Prefix {
139
}
140
141
// Node serializes the HAMT structure into a merkledag node with unixfs formatting
142
-func (ds *HamtShard) Node() (node.Node, error) {
142
+func (ds *HamtShard) Node() (ipld.Node, error) {
143
out := new(dag.ProtoNode)
144
out.SetPrefix(ds.prefix)
145
@@ -196,11 +196,11 @@ func (ds *HamtShard) Node() (node.Node, error) {
196
197
type shardValue struct {
198
key string
199
- val *node.Link
199
+ val *ipld.Link
200
}
201
202
// Link returns a link to this node
203
-func (sv *shardValue) Link() (*node.Link, error) {
203
+func (sv *shardValue) Link() (*ipld.Link, error) {
204
return sv.val, nil
205
}
206
@@ -221,14 +221,14 @@ func (ds *HamtShard) Label() string {
221
}
222
223
// Set sets 'name' = nd in the HAMT
224
-func (ds *HamtShard) Set(ctx context.Context, name string, nd node.Node) error {
224
+func (ds *HamtShard) Set(ctx context.Context, name string, nd ipld.Node) error {
225
hv := &hashBits{b: hash([]byte(name))}
226
err := ds.dserv.Add(ctx, nd)
227
if err != nil {
228
return err
229
}
230
231
- lnk, err := node.MakeLink(nd)
231
+ lnk, err := ipld.MakeLink(nd)
232
if err != nil {
233
return err
234
}
@@ -244,10 +244,10 @@ func (ds *HamtShard) Remove(ctx context.Context, name string) error {
244
}
245
246
// Find searches for a child node by 'name' within this hamt
247
-func (ds *HamtShard) Find(ctx context.Context, name string) (*node.Link, error) {
247
+func (ds *HamtShard) Find(ctx context.Context, name string) (*ipld.Link, error) {
248
hv := &hashBits{b: hash([]byte(name))}
249
250
- var out *node.Link
250
+ var out *ipld.Link
251
err := ds.getValue(ctx, hv, name, func(sv *shardValue) error {
252
out = sv.val
253
return nil
@@ -331,7 +331,7 @@ func (ds *HamtShard) setChild(i int, c child) {
331
}
332
333
// Link returns a merklelink to this shard node
334
-func (ds *HamtShard) Link() (*node.Link, error) {
334
+func (ds *HamtShard) Link() (*ipld.Link, error) {
335
nd, err := ds.Node()
336
if err != nil {
337
return nil, err
@@ -342,10 +342,10 @@ func (ds *HamtShard) Link() (*node.Link, error) {
342
return nil, err
343
}
344
345
- return node.MakeLink(nd)
345
+ return ipld.MakeLink(nd)
346
}
347
348
-func (ds *HamtShard) insertChild(idx int, key string, lnk *node.Link) error {
348
+func (ds *HamtShard) insertChild(idx int, key string, lnk *ipld.Link) error {
349
if lnk == nil {
350
return os.ErrNotExist
351
}
@@ -360,7 +360,7 @@ func (ds *HamtShard) insertChild(idx int, key string, lnk *node.Link) error {
360
}
361
362
ds.children = append(ds.children[:i], append([]child{sv}, ds.children[i:]...)...)
363
- ds.nd.SetLinks(append(ds.nd.Links()[:i], append([]*node.Link{nil}, ds.nd.Links()[i:]...)...))
363
+ ds.nd.SetLinks(append(ds.nd.Links()[:i], append([]*ipld.Link{nil}, ds.nd.Links()[i:]...)...))
364
return nil
365
}
366
@@ -401,16 +401,16 @@ func (ds *HamtShard) getValue(ctx context.Context, hv *hashBits, key string, cb
401
return os.ErrNotExist
402
}
403
404
-func (ds *HamtShard) EnumLinks(ctx context.Context) ([]*node.Link, error) {
405
- var links []*node.Link
406
- err := ds.ForEachLink(ctx, func(l *node.Link) error {
404
+func (ds *HamtShard) EnumLinks(ctx context.Context) ([]*ipld.Link, error) {
405
+ var links []*ipld.Link
406
+ err := ds.ForEachLink(ctx, func(l *ipld.Link) error {
407
links = append(links, l)
408
return nil
409
})
410
return links, err
411
}
412
413
-func (ds *HamtShard) ForEachLink(ctx context.Context, f func(*node.Link) error) error {
413
+func (ds *HamtShard) ForEachLink(ctx context.Context, f func(*ipld.Link) error) error {
414
return ds.walkTrie(ctx, func(sv *shardValue) error {
415
lnk := sv.val
416
lnk.Name = sv.key
@@ -452,7 +452,7 @@ func (ds *HamtShard) walkTrie(ctx context.Context, cb func(*shardValue) error) e
452
return nil
453
}
454
455
-func (ds *HamtShard) modifyValue(ctx context.Context, hv *hashBits, key string, val *node.Link) error {
455
+func (ds *HamtShard) modifyValue(ctx context.Context, hv *hashBits, key string, val *ipld.Link) error {
456
idx := hv.Next(ds.tableSizeLg2)
457
458
if ds.bitfield.Bit(idx) != 1 {
unixfs/hamt/hamt_stress_test.go
+2
-2
@@ -11,7 +11,7 @@ import (
11
mdtest "github.com/ipfs/go-ipfs/merkledag/test"
12
ft "github.com/ipfs/go-ipfs/unixfs"
13
14
- node "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
14
+ ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
15
)
16
17
func getNames(prefix string, count int) []string {
@@ -113,7 +113,7 @@ func validateOpSetCompletion(t *testing.T, s *HamtShard, keep, temp []string) er
113
return nil
114
}
115
116
-func executeOpSet(t *testing.T, ds node.DAGService, width int, ops []testOp) (*HamtShard, error) {
116
+func executeOpSet(t *testing.T, ds ipld.DAGService, width int, ops []testOp) (*HamtShard, error) {
117
ctx := context.TODO()
118
s, err := NewHamtShard(ds, width)
119
if err != nil {
unixfs/hamt/hamt_test.go
+5
-5
@@ -14,7 +14,7 @@ import (
14
dagutils "github.com/ipfs/go-ipfs/merkledag/utils"
15
ft "github.com/ipfs/go-ipfs/unixfs"
16
17
- node "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
17
+ ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
18
)
19
20
func shuffle(seed int64, arr []string) {
@@ -26,11 +26,11 @@ func shuffle(seed int64, arr []string) {
26
}
27
}
28
29
-func makeDir(ds node.DAGService, size int) ([]string, *HamtShard, error) {
29
+func makeDir(ds ipld.DAGService, size int) ([]string, *HamtShard, error) {
30
return makeDirWidth(ds, size, 256)
31
}
32
33
-func makeDirWidth(ds node.DAGService, size, width int) ([]string, *HamtShard, error) {
33
+func makeDirWidth(ds ipld.DAGService, size, width int) ([]string, *HamtShard, error) {
34
ctx := context.Background()
35
36
s, _ := NewHamtShard(ds, width)
@@ -74,7 +74,7 @@ func assertLink(s *HamtShard, name string, found bool) error {
74
}
75
}
76
77
-func assertSerializationWorks(ds node.DAGService, s *HamtShard) error {
77
+func assertSerializationWorks(ds ipld.DAGService, s *HamtShard) error {
78
ctx, cancel := context.WithCancel(context.Background())
79
defer cancel()
80
nd, err := s.Node()
@@ -512,7 +512,7 @@ func TestSetHamtChild(t *testing.T) {
512
}
513
}
514
515
-func printDiff(ds node.DAGService, a, b *dag.ProtoNode) {
515
+func printDiff(ds ipld.DAGService, a, b *dag.ProtoNode) {
516
diff, err := dagutils.Diff(context.TODO(), ds, a, b)
517
if err != nil {
518
panic(err)
unixfs/io/dagreader.go
+2
-2
@@ -11,7 +11,7 @@ import (
11
ftpb "github.com/ipfs/go-ipfs/unixfs/pb"
12
13
proto "gx/ipfs/QmZ4Qi3GaRbjcx28Sme5eMH7RQjGkt8wHxt2a65oLaeFEV/gogo-protobuf/proto"
14
- node "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
14
+ ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
15
)
16
17
var ErrIsDir = errors.New("this dag node is a directory")
@@ -34,7 +34,7 @@ type ReadSeekCloser interface {
34
35
// NewDagReader creates a new reader object that reads the data represented by
36
// the given node, using the passed in DAGService for data retreival
37
-func NewDagReader(ctx context.Context, n node.Node, serv node.DAGService) (DagReader, error) {
37
+func NewDagReader(ctx context.Context, n ipld.Node, serv ipld.DAGService) (DagReader, error) {
38
switch n := n.(type) {
39
case *mdag.RawNode:
40
return NewBufDagReader(n.RawData()), nil
unixfs/io/dirbuilder.go
+9
-9
@@ -10,7 +10,7 @@ import (
10
hamt "github.com/ipfs/go-ipfs/unixfs/hamt"
11
cid "gx/ipfs/QmcZfnkapfECQGcLZaf9B79NRg7cRa9EnZh4LSbkCzwNvY/go-cid"
12
13
- node "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
13
+ ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
14
)
15
16
// ShardSplitThreshold specifies how large of an unsharded directory
@@ -26,14 +26,14 @@ var UseHAMTSharding = false
26
var DefaultShardWidth = 256
27
28
type Directory struct {
29
- dserv node.DAGService
29
+ dserv ipld.DAGService
30
dirnode *mdag.ProtoNode
31
32
shard *hamt.HamtShard
33
}
34
35
// NewDirectory returns a Directory. It needs a DAGService to add the Children
36
-func NewDirectory(dserv node.DAGService) *Directory {
36
+func NewDirectory(dserv ipld.DAGService) *Directory {
37
db := new(Directory)
38
db.dserv = dserv
39
if UseHAMTSharding {
@@ -53,7 +53,7 @@ var ErrNotADir = fmt.Errorf("merkledag node was not a directory or shard")
53
54
// NewDirectoryFromNode loads a unixfs directory from the given IPLD node and
55
// DAGService.
56
-func NewDirectoryFromNode(dserv node.DAGService, nd node.Node) (*Directory, error) {
56
+func NewDirectoryFromNode(dserv ipld.DAGService, nd ipld.Node) (*Directory, error) {
57
pbnd, ok := nd.(*mdag.ProtoNode)
58
if !ok {
59
return nil, ErrNotADir
@@ -96,7 +96,7 @@ func (d *Directory) SetPrefix(prefix *cid.Prefix) {
96
}
97
98
// AddChild adds a (name, key)-pair to the root node.
99
-func (d *Directory) AddChild(ctx context.Context, name string, nd node.Node) error {
99
+func (d *Directory) AddChild(ctx context.Context, name string, nd ipld.Node) error {
100
if d.shard == nil {
101
if !UseHAMTSharding {
102
_ = d.dirnode.RemoveNodeLink(name)
@@ -136,7 +136,7 @@ func (d *Directory) switchToSharding(ctx context.Context) error {
136
return nil
137
}
138
139
-func (d *Directory) ForEachLink(ctx context.Context, f func(*node.Link) error) error {
139
+func (d *Directory) ForEachLink(ctx context.Context, f func(*ipld.Link) error) error {
140
if d.shard == nil {
141
for _, l := range d.dirnode.Links() {
142
if err := f(l); err != nil {
@@ -149,7 +149,7 @@ func (d *Directory) ForEachLink(ctx context.Context, f func(*node.Link) error) e
149
return d.shard.ForEachLink(ctx, f)
150
}
151
152
-func (d *Directory) Links(ctx context.Context) ([]*node.Link, error) {
152
+func (d *Directory) Links(ctx context.Context) ([]*ipld.Link, error) {
153
if d.shard == nil {
154
return d.dirnode.Links(), nil
155
}
@@ -157,7 +157,7 @@ func (d *Directory) Links(ctx context.Context) ([]*node.Link, error) {
157
return d.shard.EnumLinks(ctx)
158
}
159
160
-func (d *Directory) Find(ctx context.Context, name string) (node.Node, error) {
160
+func (d *Directory) Find(ctx context.Context, name string) (ipld.Node, error) {
161
if d.shard == nil {
162
lnk, err := d.dirnode.GetNodeLink(name)
163
switch err {
@@ -188,7 +188,7 @@ func (d *Directory) RemoveChild(ctx context.Context, name string) error {
188
}
189
190
// GetNode returns the root of this Directory
191
-func (d *Directory) GetNode() (node.Node, error) {
191
+func (d *Directory) GetNode() (ipld.Node, error) {
192
if d.shard == nil {
193
return d.dirnode, nil
194
}
unixfs/io/pbdagreader.go
+7
-7
@@ -12,12 +12,12 @@ import (
12
13
proto "gx/ipfs/QmZ4Qi3GaRbjcx28Sme5eMH7RQjGkt8wHxt2a65oLaeFEV/gogo-protobuf/proto"
14
cid "gx/ipfs/QmcZfnkapfECQGcLZaf9B79NRg7cRa9EnZh4LSbkCzwNvY/go-cid"
15
- node "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
15
+ ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
16
)
17
18
// DagReader provides a way to easily read the data contained in a dag.
19
type pbDagReader struct {
20
- serv node.DAGService
20
+ serv ipld.DAGService
21
22
// the node being read
23
node *mdag.ProtoNode
@@ -30,7 +30,7 @@ type pbDagReader struct {
30
buf ReadSeekCloser
31
32
// NodePromises for each of 'nodes' child links
33
- promises []*node.NodePromise
33
+ promises []*ipld.NodePromise
34
35
// the cid of each child of the current node
36
links []*cid.Cid
@@ -51,14 +51,14 @@ type pbDagReader struct {
51
var _ DagReader = (*pbDagReader)(nil)
52
53
// NewPBFileReader constructs a new PBFileReader.
54
-func NewPBFileReader(ctx context.Context, n *mdag.ProtoNode, pb *ftpb.Data, serv node.DAGService) *pbDagReader {
54
+func NewPBFileReader(ctx context.Context, n *mdag.ProtoNode, pb *ftpb.Data, serv ipld.DAGService) *pbDagReader {
55
fctx, cancel := context.WithCancel(ctx)
56
curLinks := getLinkCids(n)
57
return &pbDagReader{
58
node: n,
59
serv: serv,
60
buf: NewBufDagReader(pb.GetData()),
61
- promises: make([]*node.NodePromise, len(curLinks)),
61
+ promises: make([]*ipld.NodePromise, len(curLinks)),
62
links: curLinks,
63
ctx: fctx,
64
cancel: cancel,
@@ -75,7 +75,7 @@ func (dr *pbDagReader) preloadNextNodes(ctx context.Context) {
75
end = len(dr.links)
76
}
77
78
- for i, p := range node.GetNodes(ctx, dr.serv, dr.links[beg:end]) {
78
+ for i, p := range ipld.GetNodes(ctx, dr.serv, dr.links[beg:end]) {
79
dr.promises[beg+i] = p
80
}
81
}
@@ -135,7 +135,7 @@ func (dr *pbDagReader) precalcNextBuf(ctx context.Context) error {
135
}
136
}
137
138
-func getLinkCids(n node.Node) []*cid.Cid {
138
+func getLinkCids(n ipld.Node) []*cid.Cid {
139
links := n.Links()
140
out := make([]*cid.Cid, 0, len(links))
141
for _, l := range links {
unixfs/io/resolve.go
+2
-2
@@ -7,12 +7,12 @@ import (
7
ft "github.com/ipfs/go-ipfs/unixfs"
8
hamt "github.com/ipfs/go-ipfs/unixfs/hamt"
9
10
- node "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
10
+ ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
11
)
12
13
// ResolveUnixfsOnce resolves a single hop of a path through a graph in a
14
// unixfs context. This includes handling traversing sharded directories.
15
-func ResolveUnixfsOnce(ctx context.Context, ds node.DAGService, nd node.Node, names []string) (*node.Link, []string, error) {
15
+func ResolveUnixfsOnce(ctx context.Context, ds ipld.DAGService, nd ipld.Node, names []string) (*ipld.Link, []string, error) {
16
switch nd := nd.(type) {
17
case *dag.ProtoNode:
18
upb, err := ft.FromBytes(nd.Data())
unixfs/mod/dagmodifier.go
+10
-10
@@ -16,7 +16,7 @@ import (
16
17
proto "gx/ipfs/QmZ4Qi3GaRbjcx28Sme5eMH7RQjGkt8wHxt2a65oLaeFEV/gogo-protobuf/proto"
18
cid "gx/ipfs/QmcZfnkapfECQGcLZaf9B79NRg7cRa9EnZh4LSbkCzwNvY/go-cid"
19
- node "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
19
+ ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
20
)
21
22
var ErrSeekFail = errors.New("failed to seek properly")
@@ -29,8 +29,8 @@ var writebufferSize = 1 << 21
29
// perform surgery on a DAG 'file'
30
// Dear god, please rename this to something more pleasant
31
type DagModifier struct {
32
- dagserv node.DAGService
33
- curNode node.Node
32
+ dagserv ipld.DAGService
33
+ curNode ipld.Node
34
35
splitter chunk.SplitterGen
36
ctx context.Context
@@ -52,7 +52,7 @@ var ErrNotUnixfs = fmt.Errorf("dagmodifier only supports unixfs nodes (proto or
52
// created nodes will be inherted from the passed in node. If the Cid
53
// version if not 0 raw leaves will also be enabled. The Prefix and
54
// RawLeaves options can be overridden by changing them after the call.
55
-func NewDagModifier(ctx context.Context, from node.Node, serv node.DAGService, spl chunk.SplitterGen) (*DagModifier, error) {
55
+func NewDagModifier(ctx context.Context, from ipld.Node, serv ipld.DAGService, spl chunk.SplitterGen) (*DagModifier, error) {
56
switch from.(type) {
57
case *mdag.ProtoNode, *mdag.RawNode:
58
// ok
@@ -167,7 +167,7 @@ func (dm *DagModifier) Size() (int64, error) {
167
return int64(fileSize), nil
168
}
169
170
-func fileSize(n node.Node) (uint64, error) {
170
+func fileSize(n ipld.Node) (uint64, error) {
171
switch nd := n.(type) {
172
case *mdag.ProtoNode:
173
f, err := ft.FromBytes(nd.Data())
@@ -231,7 +231,7 @@ func (dm *DagModifier) Sync() error {
231
// modifyDag writes the data in 'data' over the data in 'node' starting at 'offset'
232
// returns the new key of the passed in node and whether or not all the data in the reader
233
// has been consumed.
234
-func (dm *DagModifier) modifyDag(n node.Node, offset uint64, data io.Reader) (*cid.Cid, bool, error) {
234
+func (dm *DagModifier) modifyDag(n ipld.Node, offset uint64, data io.Reader) (*cid.Cid, bool, error) {
235
// If we've reached a leaf node.
236
if len(n.Links()) == 0 {
237
switch nd0 := n.(type) {
@@ -353,7 +353,7 @@ func (dm *DagModifier) modifyDag(n node.Node, offset uint64, data io.Reader) (*c
353
}
354
355
// appendData appends the blocks from the given chan to the end of this dag
356
-func (dm *DagModifier) appendData(nd node.Node, spl chunk.Splitter) (node.Node, error) {
356
+func (dm *DagModifier) appendData(nd ipld.Node, spl chunk.Splitter) (ipld.Node, error) {
357
switch nd := nd.(type) {
358
case *mdag.ProtoNode, *mdag.RawNode:
359
dbp := &help.DagBuilderParams{
@@ -425,7 +425,7 @@ func (dm *DagModifier) CtxReadFull(ctx context.Context, b []byte) (int, error) {
425
}
426
427
// GetNode gets the modified DAG Node
428
-func (dm *DagModifier) GetNode() (node.Node, error) {
428
+func (dm *DagModifier) GetNode() (ipld.Node, error) {
429
err := dm.Sync()
430
if err != nil {
431
return nil, err
@@ -510,7 +510,7 @@ func (dm *DagModifier) Truncate(size int64) error {
510
}
511
512
// dagTruncate truncates the given node to 'size' and returns the modified Node
513
-func dagTruncate(ctx context.Context, n node.Node, size uint64, ds node.DAGService) (node.Node, error) {
513
+func dagTruncate(ctx context.Context, n ipld.Node, size uint64, ds ipld.DAGService) (ipld.Node, error) {
514
if len(n.Links()) == 0 {
515
switch nd := n.(type) {
516
case *mdag.ProtoNode:
@@ -533,7 +533,7 @@ func dagTruncate(ctx context.Context, n node.Node, size uint64, ds node.DAGServi
533
534
var cur uint64
535
end := 0
536
- var modified node.Node
536
+ var modified ipld.Node
537
ndata := new(ft.FSNode)
538
for i, lnk := range nd.Links() {
539
child, err := lnk.GetNode(ctx, ds)
unixfs/test/utils.go
+6
-6
@@ -18,7 +18,7 @@ import (
18
u "gx/ipfs/QmNiJuT8Ja3hMVpBHXv3Q6dwmperaQ6JjLtpMQgMCD7xvx/go-ipfs-util"
19
mh "gx/ipfs/QmZyZDi491cCNTLfAhwcaDii2Kg4pwKRkhqQzURGDvY6ua/go-multihash"
20
cid "gx/ipfs/QmcZfnkapfECQGcLZaf9B79NRg7cRa9EnZh4LSbkCzwNvY/go-cid"
21
- node "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
21
+ ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
22
)
23
24
func SizeSplitterGen(size int64) chunk.SplitterGen {
@@ -28,7 +28,7 @@ func SizeSplitterGen(size int64) chunk.SplitterGen {
28
}
29
30
// GetDAGServ returns a mock DAGService.
31
-func GetDAGServ() node.DAGService {
31
+func GetDAGServ() ipld.DAGService {
32
return mdagmock.Mock()
33
}
34
@@ -53,7 +53,7 @@ func init() {
53
}
54
55
// GetNode returns a unixfs file node with the specified data.
56
-func GetNode(t testing.TB, dserv node.DAGService, data []byte, opts NodeOpts) node.Node {
56
+func GetNode(t testing.TB, dserv ipld.DAGService, data []byte, opts NodeOpts) ipld.Node {
57
in := bytes.NewReader(data)
58
59
dbp := h.DagBuilderParams{
@@ -72,12 +72,12 @@ func GetNode(t testing.TB, dserv node.DAGService, data []byte, opts NodeOpts) no
72
}
73
74
// GetEmptyNode returns an empty unixfs file node.
75
-func GetEmptyNode(t testing.TB, dserv node.DAGService, opts NodeOpts) node.Node {
75
+func GetEmptyNode(t testing.TB, dserv ipld.DAGService, opts NodeOpts) ipld.Node {
76
return GetNode(t, dserv, []byte{}, opts)
77
}
78
79
// GetRandomNode returns a random unixfs file node.
80
-func GetRandomNode(t testing.TB, dserv node.DAGService, size int64, opts NodeOpts) ([]byte, node.Node) {
80
+func GetRandomNode(t testing.TB, dserv ipld.DAGService, size int64, opts NodeOpts) ([]byte, ipld.Node) {
81
in := io.LimitReader(u.NewTimeSeededRand(), size)
82
buf, err := ioutil.ReadAll(in)
83
if err != nil {
@@ -101,7 +101,7 @@ func ArrComp(a, b []byte) error {
101
}
102
103
// PrintDag pretty-prints the given dag to stdout.
104
-func PrintDag(nd *mdag.ProtoNode, ds node.DAGService, indent int) {
104
+func PrintDag(nd *mdag.ProtoNode, ds ipld.DAGService, indent int) {
105
pbd, err := ft.FromBytes(nd.Data())
106
if err != nil {
107
panic(err)