diff --git a/car.js b/car.js index 50c817a..9224bdd 100644 --- a/car.js +++ b/car.js @@ -175,7 +175,7 @@ async function traverseBlock (block, get, car, concurrency = 1, seen = new Set() const cid = await block.cid() await car.put(cid, block.encodeUnsafe()) seen.add(cid.toString('base58btc')) - if (cid.codec === 'raw') { + if (cid.code === 0x55) { // raw return } const reader = block.reader() @@ -204,8 +204,8 @@ async function traverseBlock (block, get, car, concurrency = 1, seen = new Set() * @memberof CarDatastore * @static * @async - * @param {Block} root the root of the graph to start at, this block will be - * included in the CAR and its CID will be set as the single root. + * @param {CID} root the CID of the root of the graph to start at, this block + * will be included in the CAR and the CID will be set as the single root. * @param {AsyncFunction} get an `async` function that takes a CID and returns * a `Block`. Can be used to attach to an arbitrary data store. * @param {CarDatastore} car a writable `CarDatastore` that has not yet been diff --git a/package.json b/package.json index dc0ee54..f31960f 100644 --- a/package.json +++ b/package.json @@ -31,12 +31,13 @@ }, "homepage": "https://github.com/rvagg/js-datastore-car#readme", "devDependencies": { + "@ipld/block": "^5.1.1", "@ipld/dag-cbor": "^1.1.3", "assert": "^2.0.0", "bl": "^4.0.2", - "cids": "^0.8.0", + "cids": "^0.8.3", "garbage": "0.0.0", - "hundreds": "0.0.2", + "hundreds": "0.0.7", "ipld-dag-pb": "^0.18.5", "jsdoc4readme": "^1.3.0", "mocha": "^7.2.0", diff --git a/test/test-complete-graph.js b/test/test-complete-graph.js index 30e4cc9..7ac934e 100644 --- a/test/test-complete-graph.js +++ b/test/test-complete-graph.js @@ -1,8 +1,11 @@ /* eslint-env mocha */ const assert = require('assert') -const { writeStream, readBuffer, completeGraph } = require('../') -const Block = require('@ipld/block') +const multiformats = require('multiformats/basics.js') +multiformats.add(require('@ipld/dag-cbor')) +multiformats.multibase.add(require('multiformats/bases/base58.js')) +const { writeStream, readBuffer, completeGraph } = require('../car')(multiformats) +const Block = require('@ipld/block')(multiformats) const { PassThrough } = require('stream') const same = assert.deepStrictEqual @@ -15,7 +18,7 @@ function all (car) { const block = Block.create(encoded, link) yield block const cid = await block.cid() - if (cid.codec === 'raw') { + if (cid.code === 0x55) { return }