-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: initial implementation #1
Conversation
4326122
to
7fec9d1
Compare
7fec9d1
to
7675777
Compare
src/index.js
Outdated
function getHasher (multihashCode) { | ||
switch (multihashCode) { | ||
case sha256.code: | ||
return sha256 | ||
case sha512.code: | ||
return sha512 | ||
case murmur3128.code: | ||
return murmur3128 | ||
case murmur332.code: | ||
return murmur332 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's really hard to spot if we get one of these wrong... I kinda love this style, where you convert a list of things to the map init format:
const hashMap = new Map([sha256, sha512, murmer3128, ...].map(hash => [hash.code, hash]))
src/index.js
Outdated
console.log('hasher', hasher, block.bytes) | ||
const bytesHash = await hasher.digest(block.bytes) | ||
|
||
console.log('has', bytesHash) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
console.log('hasher', hasher, block.bytes) | |
const bytesHash = await hasher.digest(block.bytes) | |
console.log('has', bytesHash) | |
const bytesHash = await hasher.digest(block.bytes) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor, but we could re-use the wording from https://github.com/multiformats/js-multiformats/blob/master/src/block.js#L261
so the same error has the same string.
Co-authored-by: Oli Evans <[email protected]>
Adds initial implementation to validate
@ipld/car
blocks for the supported formats by web3.storage. It verifies if block is encoded with one of the hashers supported, as well as if bytes are not bad for the hash