Skip to content
This repository has been archived by the owner on Dec 6, 2022. It is now read-only.

Commit

Permalink
make completeGraph work with multiformats
Browse files Browse the repository at this point in the history
  • Loading branch information
rvagg committed Jul 1, 2020
1 parent a2cd900 commit d225246
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
6 changes: 3 additions & 3 deletions car.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
9 changes: 6 additions & 3 deletions test/test-complete-graph.js
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
}

Expand Down

0 comments on commit d225246

Please sign in to comment.