Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request changes CID representation to a glorified ArrayBuffer view (as per multiformats/js-cid#111 (comment) and discussions in other higher bandwidth channels). Primary goal here is to illustrate and discuss the concept, which is why it end up mixing bunch of things (we can spin smaller pull request from this as necessary).
Overview
Mail goal is to make CID just be a glorified view over the binary CID (just like all the other typed arrays). That is to say it complies with
ArrayBufferView
interface as defined below:CID
can represent view into the larger buffer. This provides nice benefits when using binary protocol to move data across threads or processes.This is not strictly necessary, but it simplifies
CID
constructor so it's in the spirit of otherArrayBufferView
s.CID.from(v)
(again as other views) to makeCID
from string and all other supported inputs.CID.create(version, code, bytes)
for creatingCID
out of given parameters.Renames previously existing
buffer
field tobytes
, becausebuffer
needs to be anArrayBuffer
. It is also aligned with recent change in old CIDs as per fix: replace node buffers with uint8arrays js-cid#117