@cryptotaxi247 / kubo / commits / 33bb77072

coreapi unixfs: separate option to enable inlining

License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com> This commit was moved from ipfs/interface-go-ipfs-core@88ca0a07599ddd51c3db3864b99c1da87bf87eee This commit was moved from ipfs/boxo@80a937abb79a84f303465f05d86b206e1e90ff75

Łukasz Magiera committed Oct 2, 2018 at 09:42 UTC 33bb77072255f75e8a5a777069b9425a9f81e315
1 file changed +21 -4
core/coreiface/options/unixfs.go
+21 -4
@@ -20,6 +20,7 @@ type UnixfsAddSettings struct {
20 CidVersion int
21 MhType uint64
22
23 + Inline bool
24 InlineLimit int
25 RawLeaves bool
26 RawLeavesSet bool
@@ -39,7 +40,8 @@ func UnixfsAddOptions(opts ...UnixfsAddOption) (*UnixfsAddSettings, cid.Prefix,
40 CidVersion: -1,
41 MhType: mh.SHA2_256,
42
42 - InlineLimit: 0,
43 + Inline: false,
44 + InlineLimit: 32,
45 RawLeaves: false,
46 RawLeavesSet: false,
47
@@ -124,11 +126,26 @@ func (unixfsOpts) RawLeaves(enable bool) UnixfsAddOption {
126 }
127 }
128
129 +// Inline tells the adder to inline small blocks into CIDs
130 +func (unixfsOpts) Inline(enable bool) UnixfsAddOption {
131 + return func(settings *UnixfsAddSettings) error {
132 + settings.Inline = enable
133 + return nil
134 + }
135 +}
136 +
137 // InlineLimit sets the amount of bytes below which blocks will be encoded
128 -// directly into CID instead of being stored and addressed by it's hash
138 +// directly into CID instead of being stored and addressed by it's hash.
139 +// Specifying this option won't enable block inlining. For that use `Inline`
140 +// option. Default: 32 bytes
141 +//
142 +// Note that while there is no hard limit on the number of bytes, it should
143 +// be kept at a reasonably low value, like 64 bytes if you intend to display
144 +// these hashes. Larger values like 256 bytes will work fine, but may affect
145 +// de-duplication of smaller blocks.
146 //
130 -// Note that while there is no hard limit on the number of bytes here, it should
131 -// be kept at something reasonably low like 32b (default for 'ipfs add')
147 +// Setting this value too high may cause various problems, such as render some
148 +// blocks unfetchable
149 func (unixfsOpts) InlineLimit(limit int) UnixfsAddOption {
150 return func(settings *UnixfsAddSettings) error {
151 settings.InlineLimit = limit