Skip to content

Commit 3e2f404

Browse files
committed
chore: pass options to block api
1 parent 1c80857 commit 3e2f404

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

packages/ipfs-unixfs-importer/src/utils/persist.js

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,24 @@ const persist = async (buffer, block, options) => {
2525
options.cidVersion = 1
2626
}
2727

28-
const multihash = await mh(buffer, options.hashAlg)
29-
const cid = new CID(options.cidVersion, options.codec, multihash)
30-
31-
if (!options.onlyHash) {
32-
const blockOptions = {
33-
version: options.cidVersion,
34-
pin: options.pin,
35-
cid
36-
}
37-
38-
await block.put(buffer, blockOptions)
28+
if (options.onlyHash) {
29+
return new CID(
30+
options.cidVersion,
31+
options.codec,
32+
await mh(buffer, options.hashAlg)
33+
)
3934
}
4035

36+
const {
37+
cid
38+
} = await block.put(buffer, {
39+
version: options.cidVersion,
40+
format: options.codec,
41+
mhtype: options.hashAlg,
42+
pin: options.pin,
43+
preload: options.preload
44+
})
45+
4146
return cid
4247
}
4348

0 commit comments

Comments
 (0)