Skip to content
This repository has been archived by the owner on Aug 11, 2021. It is now read-only.

Commit

Permalink
feat: add defaultHashAlg (#65)
Browse files Browse the repository at this point in the history
  • Loading branch information
richardschneider authored and vmx committed Jun 22, 2018
1 parent e892dc9 commit e095ef5
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/resolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const traverse = require('traverse')
exports = module.exports

exports.multicodec = 'dag-cbor'
exports.defaultHashAlg = 'sha2-256'

/*
* resolve: receives a path and a binary blob and returns the value on path,
Expand Down
2 changes: 1 addition & 1 deletion src/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ exports.deserialize = (data, callback) => {
exports.cid = (dagNode, callback) => {
waterfall([
(cb) => exports.serialize(dagNode, cb),
(serialized, cb) => multihashing(serialized, 'sha2-256', cb),
(serialized, cb) => multihashing(serialized, resolver.defaultHashAlg, cb),
(mh, cb) => cb(null, new CID(1, resolver.multicodec, mh))
], callback)
}
4 changes: 4 additions & 0 deletions test/resolver.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ describe('IPLD format resolver (local)', () => {
expect(resolver.multicodec).to.equal('dag-cbor')
})

it('defaultHashAlg is sha2-256', () => {
expect(resolver.defaultHashAlg).to.equal('sha2-256')
})

describe('empty node', () => {
describe('resolver.resolve', () => {
it('root', (done) => {
Expand Down

0 comments on commit e095ef5

Please sign in to comment.