coreapi unixfs: layout/chunker options
License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com> This commit was moved from ipfs/interface-go-ipfs-core@ee22ac438536720b2646e6071ecc6519f4161a0c This commit was moved from ipfs/boxo@f858a5213f527b1ff67c45692c9e481301678398
Łukasz Magiera committed
Sep 20, 2018 at 16:40 UTC
82ef32dcaf3619bc2d372ef0a634e56e159cc4e9
1 file changed
+27
core/coreiface/options/unixfs.go
+27
@@ -4,6 +4,13 @@ import (
4
mh "gx/ipfs/QmPnFwZ2JXKnXgMw8CdBPxn7FWh6LLdjUjxV1fKHuJnkr8/go-multihash"
5
)
6
7
+type Layout int
8
+
9
+const (
10
+ BalancedLayout Layout = iota
11
+ TrickleLeyout
12
+)
13
+
14
type UnixfsAddSettings struct {
15
CidVersion int
16
MhType uint64
@@ -11,6 +18,9 @@ type UnixfsAddSettings struct {
18
InlineLimit int
19
RawLeaves bool
20
RawLeavesSet bool
21
+
22
+ Chunker string
23
+ Layout Layout
24
}
25
26
type UnixfsAddOption func(*UnixfsAddSettings) error
@@ -23,6 +33,9 @@ func UnixfsAddOptions(opts ...UnixfsAddOption) (*UnixfsAddSettings, error) {
33
InlineLimit: 0,
34
RawLeaves: false,
35
RawLeavesSet: false,
36
+
37
+ Chunker: "size-262144",
38
+ Layout: BalancedLayout,
39
}
40
41
for _, opt := range opts {
@@ -67,3 +80,17 @@ func (unixfsOpts) InlineLimit(limit int) UnixfsAddOption {
80
return nil
81
}
82
}
83
+
84
+func (unixfsOpts) Chunker(chunker string) UnixfsAddOption {
85
+ return func(settings *UnixfsAddSettings) error {
86
+ settings.Chunker = chunker
87
+ return nil
88
+ }
89
+}
90
+
91
+func (unixfsOpts) Layout(layout Layout) UnixfsAddOption {
92
+ return func(settings *UnixfsAddSettings) error {
93
+ settings.Layout = layout
94
+ return nil
95
+ }
96
+}