Skip to content
This repository was archived by the owner on Apr 29, 2020. It is now read-only.

chore: update deps #26

Merged
merged 5 commits into from
Jan 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ stages:
- cov

node_js:
- '10'
- '12'

os:
- linux
Expand Down
17 changes: 9 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,19 @@
"ipld": "^0.25.0",
"ipld-dag-pb": "^0.18.0",
"ipld-in-memory": "^3.0.0",
"multicodec": "~0.5.1",
"multihashes": "~0.4.14",
"nyc": "^14.0.0",
"sinon": "^7.1.0"
"ipfs-unixfs-importer": "^0.42.0",
"multicodec": "^1.0.0",
"multihashes": "^0.4.14",
"nyc": "^15.0.0",
"sinon": "^8.0.4"
},
"dependencies": {
"async-iterator-last": "^1.0.0",
"cids": "~0.7.1",
"cids": "^0.7.1",
"err-code": "^2.0.0",
"hamt-sharding": "~0.0.2",
"ipfs-unixfs": "^0.2.0",
"ipfs-unixfs-importer": "~0.40.0"
"hamt-sharding": "^1.0.0",
"ipfs-unixfs": "^0.3.0",
"multihashing-async": "^0.8.0"
},
"contributors": [
"Alan Shaw <alan.shaw@protocol.ai>",
Expand Down
26 changes: 23 additions & 3 deletions src/utils/find-cid-in-shard.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,27 @@
'use strict'

const Bucket = require('hamt-sharding/src/bucket')
const DirSharded = require('ipfs-unixfs-importer/src/dir-sharded')
const multihashing = require('multihashing-async')

// FIXME: this is copy/pasted from ipfs-unixfs-importer/src/dir-sharded.js
const hashFn = async function (value) {
const hash = await multihashing(Buffer.from(value, 'utf8'), 'murmur3-128')

// Multihashing inserts preamble of 2 bytes. Remove it.
// Also, murmur3 outputs 128 bit but, accidently, IPFS Go's
// implementation only uses the first 64, so we must do the same
// for parity..
const justHash = hash.slice(2, 10)
const length = justHash.length
const result = Buffer.alloc(length)
// TODO: invert buffer because that's how Go impl does it
for (let i = 0; i < length; i++) {
result[length - i - 1] = justHash[i]
}

return result
}
hashFn.code = 0x22 // TODO: get this from multihashing-async?

const addLinksToHamtBucket = (links, bucket, rootBucket) => {
return Promise.all(
Expand All @@ -10,7 +30,7 @@ const addLinksToHamtBucket = (links, bucket, rootBucket) => {
const pos = parseInt(link.Name, 16)

return bucket._putObjectAt(pos, new Bucket({
hashFn: DirSharded.hashFn
hashFn
}, bucket, pos))
}

Expand Down Expand Up @@ -46,7 +66,7 @@ const findShardCid = async (node, name, ipld, context) => {
if (!context) {
context = {
rootBucket: new Bucket({
hashFn: DirSharded.hashFn
hashFn
}),
hamtDepth: 1
}
Expand Down