-
Notifications
You must be signed in to change notification settings - Fork 48
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
Support bitswap 1.1.0 and bitswap 1.0.0 using CID #76
Conversation
…g, reducing cognitive load
ab1e902
to
de99976
Compare
this is super hard to review with all the file moving and renaming. Can you please put that into a different PR? |
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.
Found some small issues but overall this looks already pretty solid. No need to move the renaming somewhere else, githubs review support for individual commits is pretty sweet at this point :)
this.key = key | ||
this.priority = isUndefined(priority) ? 1 : priority | ||
this.cid = cid | ||
this.priority = priority || 1 |
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.
This is not good, you shouldn't use ||
if the input is a number.
return this.set.get(mh.toB58String(key)) | ||
contains (cid) { | ||
const cidStr = cid.toBaseEncodedString() | ||
return !!this.set.get(cidStr) |
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.
this will break behaviour in other places, I've used this as a shortcut to avoid double lookups.
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.
Oh, you want it to continue returning the value? ok
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 okay with refactoring it so that it's not needed anymore, but there are places where changing this breaks things, that's all I wanted to point out.
const network = mockNetwork(6, (calls) => { | ||
expect(calls.connects).to.have.length(6) | ||
const m1 = new Message(true) | ||
m1.addEntry(new Buffer('hello'), cs.kMaxPriority) | ||
m1.addEntry(new Buffer('world'), cs.kMaxPriority - 1) | ||
m1.addEntry(ew Buffer('world'), cs.kMaxPriority - 1) |
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 don't think this was a good change 😛
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.
ew
:P
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.
This changed to 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.
good, because I think we are all out of ew
buffers
@diasdavid can we please move the question and answer section into individual issues, I think those all warrant discussion/thought/individual PRs and should be handled individually. |
@diasdavid 😍 thank you for writing that diagram |
Can you please update the test folder structure so it reflects the one on src? |
Absolutely, that is my plan once this gets merged. For now, it is just a place for me to collect everything.
Glad you like it :D
On it, added to the tasks |
fdac00f
to
65dbd28
Compare
@@ -70,8 +69,9 @@ class DecisionEngine { | |||
log('got task') | |||
|
|||
pull( | |||
this.blockstore.getStream(nextTask.entry.cid), | |||
this.blockstore.getStream(nextTask.entry.cid.toV0()), |
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'll change this one to multihash
, as it might look confusing.
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
@@ -168,9 +167,8 @@ class DecisionEngine { | |||
ledger.wants(entry.cid, entry.priority) | |||
|
|||
// If we already have the block, serve it | |||
this.blockstore.has(entry.cid, (err, exists) => { | |||
this.blockstore.has(entry.cid.toV0(), (err, exists) => { |
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.
and also 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
ffc4d17
to
105456b
Compare
start the work on network support
105456b
to
beff8d1
Compare
ac75d24
to
f4ca6bd
Compare
f4ca6bd
to
e892863
Compare
UpdateThis PR is pretty much in a Some remarks, Bitswap, as a thing, is really complex and it understandable that it requires a deep dive to understand, however, the code isn't really helping, I hope with this PR it welcomes more contributors as I tries to structure and refactor to minimize the cognitive overhead that one has to take in order to tinker with the code. Other than the things listed to improve in the first comment, here are some more vectors where we can improve:
@dignifiedquire thank you for adding a lot of tests to this module, it made the migration so much easier and I was very confident as I walked through it ❤️ Tomorrow I will update the Block Service to use this new bitswap and then DAG API :) |
Now the code for this PR is present on: #84 I've opened issues to handle all the concerns presented in this PR:
|
tl;dr; This PR adds support to CID and enables js-ipfs-bitswap to interop with both bitswap versions.
My initial goal was only to add the new support, however, I was having trouble to deal with the cognitive load that I was getting by having to sync in how ipfs-bitswap works and how this repo is organized each time I context switched. Since there was never a documentation/writeup, I started adding notes, later an image of the architecture and finally organized a bit the folder structure, so that the structure gives us a more intuitive way to understand what is going on. I hope this helps other people contribute and debug bitswap.
Thoughts and questions to answer
Also, during the process, I've realized that some things can be improved, that some others look like 'Go code being forced in JS land' and some that I'm simply not sure why it is the way it is. It doesn't have to be part of this PR, but I want to make sure to write them down so that we go through them later. First, here is the:
cancel
, can't we justextend
the other and add that property?What's left