Skip to content

Commit 175ddad

Browse files
authored
fix: just do what the user asked (#90)
We change some defaults based on the CID version passed, this seems like the wrong approach and debugging problems turns into whack-a-mole. Let the calling code decide the settings for the various knobs and levers instead. BREAKING CHANGES: We previously did things like set rawLeaves to true based on the CID version, now we do not.
1 parent 9e8f077 commit 175ddad

File tree

3 files changed

+12
-22
lines changed

3 files changed

+12
-22
lines changed

packages/ipfs-unixfs-importer/src/index.js

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -36,28 +36,6 @@ const defaultOptions = {
3636
module.exports = async function * (source, block, options = {}) {
3737
const opts = mergeOptions(defaultOptions, options)
3838

39-
if (options.cidVersion > 0 && options.rawLeaves === undefined) {
40-
// if the cid version is 1 or above, use raw leaves as this is
41-
// what go does.
42-
opts.rawLeaves = true
43-
}
44-
45-
if (options.hashAlg !== undefined && options.rawLeaves === undefined) {
46-
// if a non-default hash alg has been specified, use raw leaves as this is
47-
// what go does.
48-
opts.rawLeaves = true
49-
}
50-
51-
// go-ifps trickle dag defaults to unixfs raw leaves, balanced dag defaults to file leaves
52-
if (options.strategy === 'trickle') {
53-
opts.leafType = 'raw'
54-
opts.reduceSingleLeafToSelf = false
55-
}
56-
57-
if (options.format) {
58-
opts.codec = options.format
59-
}
60-
6139
let dagBuilder
6240

6341
if (typeof options.dagBuilder === 'function') {

packages/ipfs-unixfs-importer/test/hash-parity-with-go-ipfs.spec.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ strategies.forEach(strategy => {
2727
strategy: strategy
2828
}
2929

30+
if (strategy === 'trickle') {
31+
// replicate go-ipfs behaviour
32+
options.leafType = 'raw'
33+
options.reduceSingleLeafToSelf = false
34+
}
35+
3036
describe('go-ipfs interop using importer:' + strategy, () => {
3137
let ipld
3238
let block

packages/ipfs-unixfs-importer/test/importer.spec.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,12 @@ strategies.forEach((strategy) => {
319319
strategy: strategy
320320
}
321321

322+
if (strategy === 'trickle') {
323+
// replicate go-ipfs behaviour
324+
options.leafType = 'raw'
325+
options.reduceSingleLeafToSelf = false
326+
}
327+
322328
before(async () => {
323329
ipld = await inMemory(IPLD)
324330
block = blockApi(ipld)

0 commit comments

Comments
 (0)