@cryptotaxi247 / kubo / commits / 381977476

Extract: chunker: rename "chunk" to "chunker" as it is more consistent

License: MIT Signed-off-by: Hector Sanjuan <hector@protocol.ai>

Hector Sanjuan committed Feb 8, 2018 at 12:49 UTC 381977476f465842f27118c65a7a819c8111ce98
15 files changed +65 -65
core/corehttp/gateway_handler.go
+2 -2
@@ -24,7 +24,7 @@ import (
24
25 humanize "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize"
26 routing "gx/ipfs/QmTiWLZ6Fo5j4KcTVutZJ5KWRRJrbxzmxA4td8NfEdrPh7/go-libp2p-routing"
27 - chunk "gx/ipfs/QmWo8jYc19ppG7YoTsrr2kEtLRbARTJho5oNXFTR6B7Peq/go-ipfs-chunker"
27 + chunker "gx/ipfs/QmWo8jYc19ppG7YoTsrr2kEtLRbARTJho5oNXFTR6B7Peq/go-ipfs-chunker"
28 cid "gx/ipfs/QmcZfnkapfECQGcLZaf9B79NRg7cRa9EnZh4LSbkCzwNvY/go-cid"
29 ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
30 multibase "gx/ipfs/QmexBtiTTEwwn42Yi6ouKt6VqzpA6wjJgiW1oh9VfaRrup/go-multibase"
@@ -58,7 +58,7 @@ func (i *gatewayHandler) newDagFromReader(r io.Reader) (ipld.Node, error) {
58 // return ufs.AddFromReader(i.node, r.Body)
59 return importer.BuildDagFromReader(
60 i.node.DAG,
61 - chunk.DefaultSplitter(r))
61 + chunker.DefaultSplitter(r))
62 }
63
64 // TODO(btc): break this apart into separate handlers using a more expressive muxer
core/coreunix/add.go
+2 -2
@@ -26,7 +26,7 @@ import (
26 ds "gx/ipfs/QmPpegoMqhAEqjncrzArm7KVWAkCm78rqL2DPuNjhPrshg/go-datastore"
27 syncds "gx/ipfs/QmPpegoMqhAEqjncrzArm7KVWAkCm78rqL2DPuNjhPrshg/go-datastore/sync"
28 logging "gx/ipfs/QmRb5jh8z2E8hMGN2tkvs1yHynUanqnZ3UeKwgN1i9P1F8/go-log"
29 - chunk "gx/ipfs/QmWo8jYc19ppG7YoTsrr2kEtLRbARTJho5oNXFTR6B7Peq/go-ipfs-chunker"
29 + chunker "gx/ipfs/QmWo8jYc19ppG7YoTsrr2kEtLRbARTJho5oNXFTR6B7Peq/go-ipfs-chunker"
30 cid "gx/ipfs/QmcZfnkapfECQGcLZaf9B79NRg7cRa9EnZh4LSbkCzwNvY/go-cid"
31 files "gx/ipfs/QmceUdzxkimdYsgtX733uNgzf1DLHyBKN6ehGSp85ayppM/go-ipfs-cmdkit/files"
32 ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
@@ -134,7 +134,7 @@ func (adder *Adder) SetMfsRoot(r *mfs.Root) {
134
135 // Constructs a node from reader's data, and adds it. Doesn't pin.
136 func (adder *Adder) add(reader io.Reader) (ipld.Node, error) {
137 - chnk, err := chunk.FromString(reader, adder.Chunker)
137 + chnk, err := chunker.FromString(reader, adder.Chunker)
138 if err != nil {
139 return nil, err
140 }
core/coreunix/metadata_test.go
+2 -2
@@ -18,7 +18,7 @@ import (
18 u "gx/ipfs/QmNiJuT8Ja3hMVpBHXv3Q6dwmperaQ6JjLtpMQgMCD7xvx/go-ipfs-util"
19 ds "gx/ipfs/QmPpegoMqhAEqjncrzArm7KVWAkCm78rqL2DPuNjhPrshg/go-datastore"
20 dssync "gx/ipfs/QmPpegoMqhAEqjncrzArm7KVWAkCm78rqL2DPuNjhPrshg/go-datastore/sync"
21 - chunk "gx/ipfs/QmWo8jYc19ppG7YoTsrr2kEtLRbARTJho5oNXFTR6B7Peq/go-ipfs-chunker"
21 + chunker "gx/ipfs/QmWo8jYc19ppG7YoTsrr2kEtLRbARTJho5oNXFTR6B7Peq/go-ipfs-chunker"
22 cid "gx/ipfs/QmcZfnkapfECQGcLZaf9B79NRg7cRa9EnZh4LSbkCzwNvY/go-cid"
23 ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
24 )
@@ -37,7 +37,7 @@ func TestMetadata(t *testing.T) {
37 data := make([]byte, 1000)
38 u.NewTimeSeededRand().Read(data)
39 r := bytes.NewReader(data)
40 - nd, err := importer.BuildDagFromReader(ds, chunk.DefaultSplitter(r))
40 + nd, err := importer.BuildDagFromReader(ds, chunker.DefaultSplitter(r))
41 if err != nil {
42 t.Fatal(err)
43 }
fuse/readonly/ipfs_test.go
+2 -2
@@ -22,7 +22,7 @@ import (
22
23 u "gx/ipfs/QmNiJuT8Ja3hMVpBHXv3Q6dwmperaQ6JjLtpMQgMCD7xvx/go-ipfs-util"
24 ci "gx/ipfs/QmVvkK7s5imCiq3JVbL3pGfnhcCnf3LrFJPF4GE2sAoGZf/go-testutil/ci"
25 - chunk "gx/ipfs/QmWo8jYc19ppG7YoTsrr2kEtLRbARTJho5oNXFTR6B7Peq/go-ipfs-chunker"
25 + chunker "gx/ipfs/QmWo8jYc19ppG7YoTsrr2kEtLRbARTJho5oNXFTR6B7Peq/go-ipfs-chunker"
26 fstest "gx/ipfs/QmaFNtBAXX4nVMQWbUqNysXyhevUj1k4B1y5uS45LC7Vw9/fuse/fs/fstestutil"
27 ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
28 )
@@ -37,7 +37,7 @@ 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)
40 - obj, err := importer.BuildTrickleDagFromReader(nd.DAG, chunk.DefaultSplitter(read))
40 + obj, err := importer.BuildTrickleDagFromReader(nd.DAG, chunker.DefaultSplitter(read))
41 if err != nil {
42 t.Fatal(err)
43 }
importer/balanced/balanced_test.go
+4 -4
@@ -15,13 +15,13 @@ import (
15 uio "github.com/ipfs/go-ipfs/unixfs/io"
16
17 u "gx/ipfs/QmNiJuT8Ja3hMVpBHXv3Q6dwmperaQ6JjLtpMQgMCD7xvx/go-ipfs-util"
18 - chunk "gx/ipfs/QmWo8jYc19ppG7YoTsrr2kEtLRbARTJho5oNXFTR6B7Peq/go-ipfs-chunker"
18 + chunker "gx/ipfs/QmWo8jYc19ppG7YoTsrr2kEtLRbARTJho5oNXFTR6B7Peq/go-ipfs-chunker"
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 ipld.DAGService, spl chunk.Splitter) (*dag.ProtoNode, error) {
24 +func buildTestDag(ds ipld.DAGService, spl chunker.Splitter) (*dag.ProtoNode, error) {
25 dbp := h.DagBuilderParams{
26 Dagserv: ds,
27 Maxlinks: h.DefaultLinksPerBlock,
@@ -40,7 +40,7 @@ func getTestDag(t *testing.T, ds ipld.DAGService, size int64, blksize int64) (*d
40 u.NewTimeSeededRand().Read(data)
41 r := bytes.NewReader(data)
42
43 - nd, err := buildTestDag(ds, chunk.NewSizeSplitter(r, blksize))
43 + nd, err := buildTestDag(ds, chunker.NewSizeSplitter(r, blksize))
44 if err != nil {
45 t.Fatal(err)
46 }
@@ -74,7 +74,7 @@ func testFileConsistency(t *testing.T, nbytes int64, blksize int64) {
74 }
75
76 func TestBuilderConsistency(t *testing.T) {
77 - testFileConsistency(t, 100000, chunk.DefaultBlockSize)
77 + testFileConsistency(t, 100000, chunker.DefaultBlockSize)
78 }
79
80 func TestNoChunking(t *testing.T) {
importer/helpers/dagbuilder.go
+5 -5
@@ -8,7 +8,7 @@ import (
8 dag "github.com/ipfs/go-ipfs/merkledag"
9 ft "github.com/ipfs/go-ipfs/unixfs"
10
11 - chunk "gx/ipfs/QmWo8jYc19ppG7YoTsrr2kEtLRbARTJho5oNXFTR6B7Peq/go-ipfs-chunker"
11 + chunker "gx/ipfs/QmWo8jYc19ppG7YoTsrr2kEtLRbARTJho5oNXFTR6B7Peq/go-ipfs-chunker"
12 cid "gx/ipfs/QmcZfnkapfECQGcLZaf9B79NRg7cRa9EnZh4LSbkCzwNvY/go-cid"
13 files "gx/ipfs/QmceUdzxkimdYsgtX733uNgzf1DLHyBKN6ehGSp85ayppM/go-ipfs-cmdkit/files"
14 ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
@@ -18,7 +18,7 @@ import (
18 // efficiently create unixfs dag trees
19 type DagBuilderHelper struct {
20 dserv ipld.DAGService
21 - spl chunk.Splitter
21 + spl chunker.Splitter
22 recvdErr error
23 rawLeaves bool
24 nextData []byte // the next item to return.
@@ -30,7 +30,7 @@ type DagBuilderHelper struct {
30 }
31
32 // DagBuilderParams wraps configuration options to create a DagBuilderHelper
33 -// from a chunk.Splitter.
33 +// from a chunker.Splitter.
34 type DagBuilderParams struct {
35 // Maximum number of links per intermediate node
36 Maxlinks int
@@ -51,8 +51,8 @@ type DagBuilderParams struct {
51 }
52
53 // New generates a new DagBuilderHelper from the given params and a given
54 -// chunk.Splitter as data source.
55 -func (dbp *DagBuilderParams) New(spl chunk.Splitter) *DagBuilderHelper {
54 +// chunker.Splitter as data source.
55 +func (dbp *DagBuilderParams) New(spl chunker.Splitter) *DagBuilderHelper {
56 db := &DagBuilderHelper{
57 dserv: dbp.Dagserv,
58 spl: spl,
importer/importer.go
+4 -4
@@ -6,7 +6,7 @@ import (
6 "fmt"
7 "os"
8
9 - chunk "gx/ipfs/QmWo8jYc19ppG7YoTsrr2kEtLRbARTJho5oNXFTR6B7Peq/go-ipfs-chunker"
9 + chunker "gx/ipfs/QmWo8jYc19ppG7YoTsrr2kEtLRbARTJho5oNXFTR6B7Peq/go-ipfs-chunker"
10 "gx/ipfs/QmceUdzxkimdYsgtX733uNgzf1DLHyBKN6ehGSp85ayppM/go-ipfs-cmdkit/files"
11 ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
12
@@ -33,12 +33,12 @@ func BuildDagFromFile(fpath string, ds ipld.DAGService) (ipld.Node, error) {
33 }
34 defer f.Close()
35
36 - return BuildDagFromReader(ds, chunk.DefaultSplitter(f))
36 + return BuildDagFromReader(ds, chunker.DefaultSplitter(f))
37 }
38
39 // BuildDagFromReader creates a DAG given a DAGService and a Splitter
40 // implementation (Splitters are io.Readers), using a Balanced layout.
41 -func BuildDagFromReader(ds ipld.DAGService, spl chunk.Splitter) (ipld.Node, error) {
41 +func BuildDagFromReader(ds ipld.DAGService, spl chunker.Splitter) (ipld.Node, error) {
42 dbp := h.DagBuilderParams{
43 Dagserv: ds,
44 Maxlinks: h.DefaultLinksPerBlock,
@@ -49,7 +49,7 @@ func BuildDagFromReader(ds ipld.DAGService, spl chunk.Splitter) (ipld.Node, erro
49
50 // BuildTrickleDagFromReader creates a DAG given a DAGService and a Splitter
51 // implementation (Splitters are io.Readers), using a Trickle Layout.
52 -func BuildTrickleDagFromReader(ds ipld.DAGService, spl chunk.Splitter) (ipld.Node, error) {
52 +func BuildTrickleDagFromReader(ds ipld.DAGService, spl chunker.Splitter) (ipld.Node, error) {
53 dbp := h.DagBuilderParams{
54 Dagserv: ds,
55 Maxlinks: h.DefaultLinksPerBlock,
importer/importer_test.go
+6 -6
@@ -11,14 +11,14 @@ import (
11 uio "github.com/ipfs/go-ipfs/unixfs/io"
12
13 u "gx/ipfs/QmNiJuT8Ja3hMVpBHXv3Q6dwmperaQ6JjLtpMQgMCD7xvx/go-ipfs-util"
14 - chunk "gx/ipfs/QmWo8jYc19ppG7YoTsrr2kEtLRbARTJho5oNXFTR6B7Peq/go-ipfs-chunker"
14 + chunker "gx/ipfs/QmWo8jYc19ppG7YoTsrr2kEtLRbARTJho5oNXFTR6B7Peq/go-ipfs-chunker"
15 ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
16 )
17
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))
21 + nd, err := BuildDagFromReader(ds, chunker.NewSizeSplitter(r, blksize))
22 if err != nil {
23 t.Fatal(err)
24 }
@@ -28,7 +28,7 @@ func getBalancedDag(t testing.TB, size int64, blksize int64) (ipld.Node, ipld.DA
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))
31 + nd, err := BuildTrickleDagFromReader(ds, chunker.NewSizeSplitter(r, blksize))
32 if err != nil {
33 t.Fatal(err)
34 }
@@ -41,7 +41,7 @@ func TestBalancedDag(t *testing.T) {
41 u.NewTimeSeededRand().Read(buf)
42 r := bytes.NewReader(buf)
43
44 - nd, err := BuildDagFromReader(ds, chunk.DefaultSplitter(r))
44 + nd, err := BuildDagFromReader(ds, chunker.DefaultSplitter(r))
45 if err != nil {
46 t.Fatal(err)
47 }
@@ -84,7 +84,7 @@ func BenchmarkTrickleReadSmallBlock(b *testing.B) {
84 func BenchmarkBalancedReadFull(b *testing.B) {
85 b.StopTimer()
86 nbytes := int64(10000000)
87 - nd, ds := getBalancedDag(b, nbytes, chunk.DefaultBlockSize)
87 + nd, ds := getBalancedDag(b, nbytes, chunker.DefaultBlockSize)
88
89 b.SetBytes(nbytes)
90 b.StartTimer()
@@ -94,7 +94,7 @@ func BenchmarkBalancedReadFull(b *testing.B) {
94 func BenchmarkTrickleReadFull(b *testing.B) {
95 b.StopTimer()
96 nbytes := int64(10000000)
97 - nd, ds := getTrickleDag(b, nbytes, chunk.DefaultBlockSize)
97 + nd, ds := getTrickleDag(b, nbytes, chunker.DefaultBlockSize)
98
99 b.SetBytes(nbytes)
100 b.StartTimer()
importer/trickle/trickle_test.go
+19 -19
@@ -16,7 +16,7 @@ import (
16 uio "github.com/ipfs/go-ipfs/unixfs/io"
17
18 u "gx/ipfs/QmNiJuT8Ja3hMVpBHXv3Q6dwmperaQ6JjLtpMQgMCD7xvx/go-ipfs-util"
19 - chunk "gx/ipfs/QmWo8jYc19ppG7YoTsrr2kEtLRbARTJho5oNXFTR6B7Peq/go-ipfs-chunker"
19 + chunker "gx/ipfs/QmWo8jYc19ppG7YoTsrr2kEtLRbARTJho5oNXFTR6B7Peq/go-ipfs-chunker"
20 ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
21 )
22
@@ -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 ipld.DAGService, spl chunk.Splitter, rawLeaves UseRawLeaves) (*merkledag.ProtoNode, error) {
35 +func buildTestDag(ds ipld.DAGService, spl chunker.Splitter, rawLeaves UseRawLeaves) (*merkledag.ProtoNode, error) {
36 dbp := h.DagBuilderParams{
37 Dagserv: ds,
38 Maxlinks: h.DefaultLinksPerBlock,
@@ -66,10 +66,10 @@ func testSizeBasedSplit(t *testing.T, rawLeaves UseRawLeaves) {
66 if testing.Short() {
67 t.SkipNow()
68 }
69 - bs := chunk.SizeSplitterGen(512)
69 + bs := chunker.SizeSplitterGen(512)
70 testFileConsistency(t, bs, 32*512, rawLeaves)
71
72 - bs = chunk.SizeSplitterGen(4096)
72 + bs = chunker.SizeSplitterGen(4096)
73 testFileConsistency(t, bs, 32*4096, rawLeaves)
74
75 // Uneven offset
@@ -82,7 +82,7 @@ func dup(b []byte) []byte {
82 return o
83 }
84
85 -func testFileConsistency(t *testing.T, bs chunk.SplitterGen, nbytes int, rawLeaves UseRawLeaves) {
85 +func testFileConsistency(t *testing.T, bs chunker.SplitterGen, nbytes int, rawLeaves UseRawLeaves) {
86 should := make([]byte, nbytes)
87 u.NewTimeSeededRand().Read(should)
88
@@ -119,7 +119,7 @@ func testBuilderConsistency(t *testing.T, rawLeaves UseRawLeaves) {
119 io.CopyN(buf, u.NewTimeSeededRand(), int64(nbytes))
120 should := dup(buf.Bytes())
121 dagserv := mdtest.Mock()
122 - nd, err := buildTestDag(dagserv, chunk.DefaultSplitter(buf), rawLeaves)
122 + nd, err := buildTestDag(dagserv, chunker.DefaultSplitter(buf), rawLeaves)
123 if err != nil {
124 t.Fatal(err)
125 }
@@ -156,7 +156,7 @@ func TestIndirectBlocks(t *testing.T) {
156 }
157
158 func testIndirectBlocks(t *testing.T, rawLeaves UseRawLeaves) {
159 - splitter := chunk.SizeSplitterGen(512)
159 + splitter := chunker.SizeSplitterGen(512)
160 nbytes := 1024 * 1024
161 buf := make([]byte, nbytes)
162 u.NewTimeSeededRand().Read(buf)
@@ -195,7 +195,7 @@ func testSeekingBasic(t *testing.T, rawLeaves UseRawLeaves) {
195
196 read := bytes.NewReader(should)
197 ds := mdtest.Mock()
198 - nd, err := buildTestDag(ds, chunk.NewSizeSplitter(read, 512), rawLeaves)
198 + nd, err := buildTestDag(ds, chunker.NewSizeSplitter(read, 512), rawLeaves)
199 if err != nil {
200 t.Fatal(err)
201 }
@@ -236,7 +236,7 @@ func testSeekToBegin(t *testing.T, rawLeaves UseRawLeaves) {
236
237 read := bytes.NewReader(should)
238 ds := mdtest.Mock()
239 - nd, err := buildTestDag(ds, chunk.NewSizeSplitter(read, 500), rawLeaves)
239 + nd, err := buildTestDag(ds, chunker.NewSizeSplitter(read, 500), rawLeaves)
240 if err != nil {
241 t.Fatal(err)
242 }
@@ -284,7 +284,7 @@ func testSeekToAlmostBegin(t *testing.T, rawLeaves UseRawLeaves) {
284
285 read := bytes.NewReader(should)
286 ds := mdtest.Mock()
287 - nd, err := buildTestDag(ds, chunk.NewSizeSplitter(read, 500), rawLeaves)
287 + nd, err := buildTestDag(ds, chunker.NewSizeSplitter(read, 500), rawLeaves)
288 if err != nil {
289 t.Fatal(err)
290 }
@@ -332,7 +332,7 @@ func testSeekEnd(t *testing.T, rawLeaves UseRawLeaves) {
332
333 read := bytes.NewReader(should)
334 ds := mdtest.Mock()
335 - nd, err := buildTestDag(ds, chunk.NewSizeSplitter(read, 500), rawLeaves)
335 + nd, err := buildTestDag(ds, chunker.NewSizeSplitter(read, 500), rawLeaves)
336 if err != nil {
337 t.Fatal(err)
338 }
@@ -362,7 +362,7 @@ func testSeekEndSingleBlockFile(t *testing.T, rawLeaves UseRawLeaves) {
362
363 read := bytes.NewReader(should)
364 ds := mdtest.Mock()
365 - nd, err := buildTestDag(ds, chunk.NewSizeSplitter(read, 5000), rawLeaves)
365 + nd, err := buildTestDag(ds, chunker.NewSizeSplitter(read, 5000), rawLeaves)
366 if err != nil {
367 t.Fatal(err)
368 }
@@ -392,7 +392,7 @@ func testSeekingStress(t *testing.T, rawLeaves UseRawLeaves) {
392
393 read := bytes.NewReader(should)
394 ds := mdtest.Mock()
395 - nd, err := buildTestDag(ds, chunk.NewSizeSplitter(read, 1000), rawLeaves)
395 + nd, err := buildTestDag(ds, chunker.NewSizeSplitter(read, 1000), rawLeaves)
396 if err != nil {
397 t.Fatal(err)
398 }
@@ -441,7 +441,7 @@ func testSeekingConsistency(t *testing.T, rawLeaves UseRawLeaves) {
441
442 read := bytes.NewReader(should)
443 ds := mdtest.Mock()
444 - nd, err := buildTestDag(ds, chunk.NewSizeSplitter(read, 500), rawLeaves)
444 + nd, err := buildTestDag(ds, chunker.NewSizeSplitter(read, 500), rawLeaves)
445 if err != nil {
446 t.Fatal(err)
447 }
@@ -489,7 +489,7 @@ func testAppend(t *testing.T, rawLeaves UseRawLeaves) {
489 // Reader for half the bytes
490 read := bytes.NewReader(should[:nbytes/2])
491 ds := mdtest.Mock()
492 - nd, err := buildTestDag(ds, chunk.NewSizeSplitter(read, 500), rawLeaves)
492 + nd, err := buildTestDag(ds, chunker.NewSizeSplitter(read, 500), rawLeaves)
493 if err != nil {
494 t.Fatal(err)
495 }
@@ -503,7 +503,7 @@ func testAppend(t *testing.T, rawLeaves UseRawLeaves) {
503 r := bytes.NewReader(should[nbytes/2:])
504
505 ctx := context.Background()
506 - nnode, err := Append(ctx, nd, dbp.New(chunk.NewSizeSplitter(r, 500)))
506 + nnode, err := Append(ctx, nd, dbp.New(chunker.NewSizeSplitter(r, 500)))
507 if err != nil {
508 t.Fatal(err)
509 }
@@ -548,7 +548,7 @@ func testMultipleAppends(t *testing.T, rawLeaves UseRawLeaves) {
548 u.NewTimeSeededRand().Read(should)
549
550 read := bytes.NewReader(nil)
551 - nd, err := buildTestDag(ds, chunk.NewSizeSplitter(read, 500), rawLeaves)
551 + nd, err := buildTestDag(ds, chunker.NewSizeSplitter(read, 500), rawLeaves)
552 if err != nil {
553 t.Fatal(err)
554 }
@@ -559,7 +559,7 @@ func testMultipleAppends(t *testing.T, rawLeaves UseRawLeaves) {
559 RawLeaves: bool(rawLeaves),
560 }
561
562 - spl := chunk.SizeSplitterGen(500)
562 + spl := chunker.SizeSplitterGen(500)
563
564 ctx := context.Background()
565 for i := 0; i < len(should); i++ {
@@ -609,7 +609,7 @@ func TestAppendSingleBytesToEmpty(t *testing.T) {
609 Maxlinks: 4,
610 }
611
612 - spl := chunk.SizeSplitterGen(500)
612 + spl := chunker.SizeSplitterGen(500)
613
614 ctx := context.Background()
615 nnode, err := Append(ctx, nd, dbp.New(spl(bytes.NewReader(data[:1]))))
merkledag/merkledag_test.go
+4 -4
@@ -23,7 +23,7 @@ import (
23 uio "github.com/ipfs/go-ipfs/unixfs/io"
24
25 u "gx/ipfs/QmNiJuT8Ja3hMVpBHXv3Q6dwmperaQ6JjLtpMQgMCD7xvx/go-ipfs-util"
26 - chunk "gx/ipfs/QmWo8jYc19ppG7YoTsrr2kEtLRbARTJho5oNXFTR6B7Peq/go-ipfs-chunker"
26 + chunker "gx/ipfs/QmWo8jYc19ppG7YoTsrr2kEtLRbARTJho5oNXFTR6B7Peq/go-ipfs-chunker"
27 cid "gx/ipfs/QmcZfnkapfECQGcLZaf9B79NRg7cRa9EnZh4LSbkCzwNvY/go-cid"
28 ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
29 blocks "gx/ipfs/Qmej7nf81hi2x2tvjRBF3mcp74sQyuDH4VMYDGd1YtXjb2/go-block-format"
@@ -136,7 +136,7 @@ func runBatchFetchTest(t *testing.T, read io.Reader) {
136 dagservs = append(dagservs, NewDAGService(bsi))
137 }
138
139 - spl := chunk.NewSizeSplitter(read, 512)
139 + spl := chunker.NewSizeSplitter(read, 512)
140
141 root, err := imp.BuildDagFromReader(dagservs[0], spl)
142 if err != nil {
@@ -228,7 +228,7 @@ func TestFetchGraph(t *testing.T) {
228 }
229
230 read := io.LimitReader(u.NewTimeSeededRand(), 1024*32)
231 - root, err := imp.BuildDagFromReader(dservs[0], chunk.NewSizeSplitter(read, 512))
231 + root, err := imp.BuildDagFromReader(dservs[0], chunker.NewSizeSplitter(read, 512))
232 if err != nil {
233 t.Fatal(err)
234 }
@@ -254,7 +254,7 @@ func TestEnumerateChildren(t *testing.T) {
254 ds := NewDAGService(bsi[0])
255
256 read := io.LimitReader(u.NewTimeSeededRand(), 1024*1024)
257 - root, err := imp.BuildDagFromReader(ds, chunk.NewSizeSplitter(read, 512))
257 + root, err := imp.BuildDagFromReader(ds, chunker.NewSizeSplitter(read, 512))
258 if err != nil {
259 t.Fatal(err)
260 }
mfs/file.go
+2 -2
@@ -9,7 +9,7 @@ import (
9 ft "github.com/ipfs/go-ipfs/unixfs"
10 mod "github.com/ipfs/go-ipfs/unixfs/mod"
11
12 - chunk "gx/ipfs/QmWo8jYc19ppG7YoTsrr2kEtLRbARTJho5oNXFTR6B7Peq/go-ipfs-chunker"
12 + chunker "gx/ipfs/QmWo8jYc19ppG7YoTsrr2kEtLRbARTJho5oNXFTR6B7Peq/go-ipfs-chunker"
13 ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
14 )
15
@@ -82,7 +82,7 @@ func (fi *File) Open(flags int, sync bool) (FileDescriptor, error) {
82 return nil, fmt.Errorf("mode not supported")
83 }
84
85 - dmod, err := mod.NewDagModifier(context.TODO(), node, fi.dserv, chunk.DefaultSplitter)
85 + dmod, err := mod.NewDagModifier(context.TODO(), node, fi.dserv, chunker.DefaultSplitter)
86 if err != nil {
87 return nil, err
88 }
mfs/mfs_test.go
+2 -2
@@ -26,7 +26,7 @@ import (
26 u "gx/ipfs/QmNiJuT8Ja3hMVpBHXv3Q6dwmperaQ6JjLtpMQgMCD7xvx/go-ipfs-util"
27 ds "gx/ipfs/QmPpegoMqhAEqjncrzArm7KVWAkCm78rqL2DPuNjhPrshg/go-datastore"
28 dssync "gx/ipfs/QmPpegoMqhAEqjncrzArm7KVWAkCm78rqL2DPuNjhPrshg/go-datastore/sync"
29 - chunk "gx/ipfs/QmWo8jYc19ppG7YoTsrr2kEtLRbARTJho5oNXFTR6B7Peq/go-ipfs-chunker"
29 + chunker "gx/ipfs/QmWo8jYc19ppG7YoTsrr2kEtLRbARTJho5oNXFTR6B7Peq/go-ipfs-chunker"
30 cid "gx/ipfs/QmcZfnkapfECQGcLZaf9B79NRg7cRa9EnZh4LSbkCzwNvY/go-cid"
31 ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
32 )
@@ -48,7 +48,7 @@ func getRandFile(t *testing.T, ds ipld.DAGService, size int64) ipld.Node {
48 }
49
50 func fileNodeFromReader(t *testing.T, ds ipld.DAGService, r io.Reader) ipld.Node {
51 - nd, err := importer.BuildDagFromReader(ds, chunk.DefaultSplitter(r))
51 + nd, err := importer.BuildDagFromReader(ds, chunker.DefaultSplitter(r))
52 if err != nil {
53 t.Fatal(err)
54 }
tar/format.go
+2 -2
@@ -15,7 +15,7 @@ import (
15 uio "github.com/ipfs/go-ipfs/unixfs/io"
16
17 logging "gx/ipfs/QmRb5jh8z2E8hMGN2tkvs1yHynUanqnZ3UeKwgN1i9P1F8/go-log"
18 - chunk "gx/ipfs/QmWo8jYc19ppG7YoTsrr2kEtLRbARTJho5oNXFTR6B7Peq/go-ipfs-chunker"
18 + chunker "gx/ipfs/QmWo8jYc19ppG7YoTsrr2kEtLRbARTJho5oNXFTR6B7Peq/go-ipfs-chunker"
19 ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
20 )
21
@@ -63,7 +63,7 @@ func ImportTar(ctx context.Context, r io.Reader, ds ipld.DAGService) (*dag.Proto
63 header.SetData(headerBytes)
64
65 if h.Size > 0 {
66 - spl := chunk.NewRabin(tr, uint64(chunk.DefaultBlockSize))
66 + spl := chunker.NewRabin(tr, uint64(chunker.DefaultBlockSize))
67 nd, err := importer.BuildDagFromReader(ds, spl)
68 if err != nil {
69 return nil, err
unixfs/mod/dagmodifier.go
+5 -5
@@ -14,7 +14,7 @@ import (
14 ft "github.com/ipfs/go-ipfs/unixfs"
15 uio "github.com/ipfs/go-ipfs/unixfs/io"
16
17 - chunk "gx/ipfs/QmWo8jYc19ppG7YoTsrr2kEtLRbARTJho5oNXFTR6B7Peq/go-ipfs-chunker"
17 + chunker "gx/ipfs/QmWo8jYc19ppG7YoTsrr2kEtLRbARTJho5oNXFTR6B7Peq/go-ipfs-chunker"
18 proto "gx/ipfs/QmZ4Qi3GaRbjcx28Sme5eMH7RQjGkt8wHxt2a65oLaeFEV/gogo-protobuf/proto"
19 cid "gx/ipfs/QmcZfnkapfECQGcLZaf9B79NRg7cRa9EnZh4LSbkCzwNvY/go-cid"
20 ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
@@ -37,7 +37,7 @@ type DagModifier struct {
37 dagserv ipld.DAGService
38 curNode ipld.Node
39
40 - splitter chunk.SplitterGen
40 + splitter chunker.SplitterGen
41 ctx context.Context
42 readCancel func()
43
@@ -55,7 +55,7 @@ type DagModifier struct {
55 // created nodes will be inherted from the passed in node. If the Cid
56 // version if not 0 raw leaves will also be enabled. The Prefix and
57 // RawLeaves options can be overridden by changing them after the call.
58 -func NewDagModifier(ctx context.Context, from ipld.Node, serv ipld.DAGService, spl chunk.SplitterGen) (*DagModifier, error) {
58 +func NewDagModifier(ctx context.Context, from ipld.Node, serv ipld.DAGService, spl chunker.SplitterGen) (*DagModifier, error) {
59 switch from.(type) {
60 case *mdag.ProtoNode, *mdag.RawNode:
61 // ok
@@ -126,7 +126,7 @@ func (zr zeroReader) Read(b []byte) (int, error) {
126 // A small blocksize is chosen to aid in deduplication
127 func (dm *DagModifier) expandSparse(size int64) error {
128 r := io.LimitReader(zeroReader{}, size)
129 - spl := chunk.NewSizeSplitter(r, 4096)
129 + spl := chunker.NewSizeSplitter(r, 4096)
130 nnode, err := dm.appendData(dm.curNode, spl)
131 if err != nil {
132 return err
@@ -356,7 +356,7 @@ func (dm *DagModifier) modifyDag(n ipld.Node, offset uint64, data io.Reader) (*c
356 }
357
358 // appendData appends the blocks from the given chan to the end of this dag
359 -func (dm *DagModifier) appendData(nd ipld.Node, spl chunk.Splitter) (ipld.Node, error) {
359 +func (dm *DagModifier) appendData(nd ipld.Node, spl chunker.Splitter) (ipld.Node, error) {
360 switch nd := nd.(type) {
361 case *mdag.ProtoNode, *mdag.RawNode:
362 dbp := &help.DagBuilderParams{
unixfs/test/utils.go
+4 -4
@@ -15,16 +15,16 @@ import (
15 ft "github.com/ipfs/go-ipfs/unixfs"
16
17 u "gx/ipfs/QmNiJuT8Ja3hMVpBHXv3Q6dwmperaQ6JjLtpMQgMCD7xvx/go-ipfs-util"
18 - chunk "gx/ipfs/QmWo8jYc19ppG7YoTsrr2kEtLRbARTJho5oNXFTR6B7Peq/go-ipfs-chunker"
18 + chunker "gx/ipfs/QmWo8jYc19ppG7YoTsrr2kEtLRbARTJho5oNXFTR6B7Peq/go-ipfs-chunker"
19 mh "gx/ipfs/QmZyZDi491cCNTLfAhwcaDii2Kg4pwKRkhqQzURGDvY6ua/go-multihash"
20 cid "gx/ipfs/QmcZfnkapfECQGcLZaf9B79NRg7cRa9EnZh4LSbkCzwNvY/go-cid"
21 ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
22 )
23
24 // SizeSplitterGen creates a generator.
25 -func SizeSplitterGen(size int64) chunk.SplitterGen {
26 - return func(r io.Reader) chunk.Splitter {
27 - return chunk.NewSizeSplitter(r, size)
25 +func SizeSplitterGen(size int64) chunker.SplitterGen {
26 + return func(r io.Reader) chunker.Splitter {
27 + return chunker.NewSizeSplitter(r, size)
28 }
29 }
30