-
Notifications
You must be signed in to change notification settings - Fork 44
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
chore: update to new multiformats #149
Conversation
Replaces multihashes with the new multiformats module BREAKING CHANGE: uses the CID class from the new multiformats module
src/index.js
Outdated
const cryptoKeys = require('libp2p-crypto/src/keys') | ||
const withIs = require('class-is') | ||
const { PeerIdProto } = require('./proto') | ||
const uint8ArrayEquals = require('uint8arrays/equals') | ||
const uint8ArrayFromString = require('uint8arrays/from-string') | ||
const uint8ArrayToString = require('uint8arrays/to-string') | ||
|
||
const IDENTITY_CODE = 0x00 |
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.
Any reason for not using multicodec
here? I would like to just have these codes in one place as the source of truth
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 think one of the design goals behind the new multiformats
module was to not have the big lookup tables that multicodec
is the guardian of.
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.
Fair enough. Probably worth adding a reference to the table just to reference where they come from? Probably to https://github.com/multiformats/multicodec/blob/master/table.csv
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.
In my journey through the codebase doing the multiformats stuff it seems that we only really use four or five of them. I think the only weirdness is when bitswap has to mess around with CID prefixes in incoming bitswap 1.1.0 messages.
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 think just adding a comment above with the multicodec table is enough here
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.
Done!
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.
LGTM! Let me know when I should release it
I've tightened up the input types for |
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.
👌🏼
@achingbrain FYI #150 should also be ready soon (also breaking change), so I would like to get these shipped together as bubbling up PeerId updates across all libp2p stack is time consuming. This will create some conflicts that will need to be addresses by the second PR to be merged |
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.
Can you also have the README updated for parse
and createFromCID
?
Co-authored-by: Vasco Santos <vasco.santos@moxy.studio>
Replaces multihashes with the new multiformats module
BREAKING CHANGE: uses the CID class from the new multiformats module and
PeerID.createFromCID
now only takesCID
instances