-
Notifications
You must be signed in to change notification settings - Fork 50
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: make blockstore identity-hash compatible #297
Conversation
creates a layer on top of blockstore which makes the blockstore compatible with identity hashes. Based off of https://github.com/ipfs/go-ipfs-blockstore/blob/master/idstore.go fix ipfs/js-ipfs#3289
package.json
Outdated
"it-map": "^1.0.2", | ||
"it-pushable": "^1.4.0", | ||
"just-safe-get": "^2.0.0", | ||
"just-safe-set": "^2.1.0", | ||
"just-safe-get": "~2.0.0", |
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.
What was the error that meant this needed to change from ^
to ~
?
src/idstore.js
Outdated
* @param {Blockstore} blockstore | ||
*/ | ||
module.exports = (blockstore) => { | ||
return createIdStore(blockstore) |
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.
Why not just export the createIdStore
function?
Nice work, thanks for submitting this. To land this could you please open a PR against js-ipfs that depends on this PR as a gh dep and add tests for identity CIDs to the interface-ipfs-core suite? At least for dag.get and block.get but anywhere these code paths will be executed. There's an overview of how to run the tests here: https://github.com/ipfs/js-ipfs/blob/master/docs/DEVELOPMENT.md#run-tests |
reset dependencies and make corrections, respond to PR comments
@achingbrain I've responded to PR comments and reset the dependencies, resolving the breaking change in the latest |
PR for js-ipfs to demonstrate fix: ipfs/js-ipfs#3616 |
do not use concrete type for block in the interface definition
- Adds support for identity hashes in ipfs-repo blockstore - Add core interface tests for block.get and dag.get when fetching identity hashes Refs: ipfs/js-ipfs-repo#297 Closes: #3289 Co-authored-by: Alex Potsides <alex@achingbrain.net>
Goals
Make the blockstore properly return blocks for "identity" CIDs (CID's where the multihash algorithm is "identity", meaning the contents of the hash are the actual data for the block, and there is no other data associated with the CID).
Implementation
idstore
based on https://github.com/ipfs/go-ipfs-blockstore/blob/master/idstore.go - this leaves the original blockstore implementation unchanged but adds a composable layer applied on top to add compatibility with identity hashes (served as the same blockstore interface)idstore
in construction ofrepo.blocks
just-safe-get
andjust-safe-set
by fixing to patch release for nowFor discussion
I based implementation for delete and put operations on the go versions, which essentially treats a put or delete for an identity hash as a no-op. However, the golang version does not return the block itself for puts, and I wasn't sure whether I should be doing that. For now, I've made it so the identity block is included in the results of puts.
Since I extracted
Blockstore
typings to an interface, to save writing them twice forblockstore
andidstore
and insure they both return the exact same types, I removed the JSDoc comments onblockstore
. I wasn't sure though if that affects what shows up in JSDocs. (I did put the type on the return value for createBaseStore)fix ipfs/js-ipfs#3289