-
Notifications
You must be signed in to change notification settings - Fork 37
refactor: use the block API from ipfs instead of ipld internals #51
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
Conversation
This improves resusability of the module as it can be used by passing part of an `ipfs` or `ipfs-http-client` instance in. It also means we no longer double-serialize blocks before adding them which delivers a small but almost unperceptible performance increase. Finally also documents the `pin` and `preload` arguments.
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.
Nice change!
|
||
module.exports = (ipld) => { | ||
// make ipld behave like the block api, some tests need to pull | ||
// data from ipld so can't use use a simple hash |
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.
typo: "use use"
Also I don't really understand this comment :) What is a simple hash (a multihash instead of a CID?)?
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.
An overloaded term, sorry - hash as in hash table, not hash as in multihash. I've updated the comments.
@@ -25,15 +25,15 @@ const defaultOptions = { | |||
maxChildrenPerNode: 174, | |||
layerRepeat: 4, | |||
wrapWithDirectory: false, | |||
pin: true, | |||
pin: false, |
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.
I'm just double checking if that's intended or a left-over from debugging.
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.
Since we switched to the block API from the IPLD API, the pinning should be done by the caller after they are done importing, because you typically want the root CID pinned recursively (e.g. 1x pin), rather than each block pinned (e.g. potentially many pins).
|
||
module.exports = (ipld) => { | ||
// make ipld behave like the block api, some tests need to pull | ||
// data from ipld so can't use use a simple hash |
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.
(same as for the exporter)
typo: "use use"
Also I don't really understand this comment :) What is a simple hash (a multihash instead of a CID?)?
This improves reusability of the module as it can be used by passing part of an
ipfs
oripfs-http-client
instance in.It also means we no longer double serialize blocks before adding them which delivers a very small performance increase (1-2%).
Finally also documents the
pin
andpreload
arguments.BREAKING CHANGE:
The importer takes a
pin
argument (previously undocumented) - it used to default totrue
but since this switches to use the block API the default has changed tofalse
, as the typical usage pattern is to pin the root block of a DAG recursively instead of every block that makes up the DAG.