@@ -18,6 +18,7 @@ import (
18
18
cmds "gx/ipfs/QmPTfgFTo9PFr1PvPKyKoeMgBvYPh6cX3aDP7DHKVbnCbi/go-ipfs-cmds"
19
19
mh "gx/ipfs/QmPnFwZ2JXKnXgMw8CdBPxn7FWh6LLdjUjxV1fKHuJnkr8/go-multihash"
20
20
pb "gx/ipfs/QmPtj12fdwuAqj9sBSTNUxBNu8kCGNp8b3o8yUzMm5GHpq/pb"
21
+ cidutil "gx/ipfs/QmPyxJ2QS7L5FhGkNYkNcXHGjDhvGHueJ4auqAstFHYxy5/go-cidutil"
21
22
cmdkit "gx/ipfs/QmSP88ryZkHSRn1fnngAaV2Vcn63WUJzAavnRM9CVdU1Ky/go-ipfs-cmdkit"
22
23
files "gx/ipfs/QmSP88ryZkHSRn1fnngAaV2Vcn63WUJzAavnRM9CVdU1Ky/go-ipfs-cmdkit/files"
23
24
offline "gx/ipfs/QmZxjqR9Qgompju73kakSoUj3rbVndAzky3oCDiBNCxPs1/go-ipfs-exchange-offline"
@@ -44,6 +45,8 @@ const (
44
45
fstoreCacheOptionName = "fscache"
45
46
cidVersionOptionName = "cid-version"
46
47
hashOptionName = "hash"
48
+ inlineOptionName = "inline"
49
+ idHashLimitOptionName = "id-hash-limit"
47
50
)
48
51
49
52
const adderOutChanSize = 8
@@ -120,6 +123,8 @@ You can now check what blocks have been created by:
120
123
cmdkit .BoolOption (fstoreCacheOptionName , "Check the filestore for pre-existing blocks. (experimental)" ),
121
124
cmdkit .IntOption (cidVersionOptionName , "CID version. Defaults to 0 unless an option that depends on CIDv1 is passed. (experimental)" ),
122
125
cmdkit .StringOption (hashOptionName , "Hash function to use. Implies CIDv1 if not sha2-256. (experimental)" ).WithDefault ("sha2-256" ),
126
+ cmdkit .BoolOption (inlineOptionName , "Inline small objects using identity hash. (experimental)" ),
127
+ cmdkit .IntOption (idHashLimitOptionName , "Identity hash maxium size. (experimental)" ).WithDefault (64 ),
123
128
},
124
129
PreRun : func (req * cmds.Request , env cmds.Environment ) error {
125
130
quiet , _ := req .Options [quietOptionName ].(bool )
@@ -173,6 +178,8 @@ You can now check what blocks have been created by:
173
178
fscache , _ := req .Options [fstoreCacheOptionName ].(bool )
174
179
cidVer , cidVerSet := req .Options [cidVersionOptionName ].(int )
175
180
hashFunStr , _ := req .Options [hashOptionName ].(string )
181
+ inline , _ := req .Options [inlineOptionName ].(bool )
182
+ idHashLimit , _ := req .Options [idHashLimitOptionName ].(int )
176
183
177
184
// The arguments are subject to the following constraints.
178
185
//
@@ -279,7 +286,11 @@ You can now check what blocks have been created by:
279
286
fileAdder .Silent = silent
280
287
fileAdder .RawLeaves = rawblks
281
288
fileAdder .NoCopy = nocopy
282
- fileAdder .CidBuilder = & prefix
289
+ fileAdder .CidBuilder = prefix
290
+
291
+ if inline {
292
+ fileAdder .CidBuilder = cidutil.InlineBuilder {fileAdder .CidBuilder , idHashLimit }
293
+ }
283
294
284
295
if hash {
285
296
md := dagtest .Mock ()
0 commit comments