This repository was archived by the owner on Mar 10, 2020. It is now read-only.
fix: block.put() options #793
Closed
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.
So, this contains numerous fixes to block.put() some of which break the current tests because the tests are actually broken.
Prior to this patch, options passed in were simply ignored. The tests for those options showed false positives because the tests are passing in the default encoding values (dag-pb, sha2-256).
However, go-ipfs currently fails when trying to use
/block/put
for a dag node, you have to use/dag/put
instead. So, I modified ourblock.put()
API to check the format and call the dag put API instead, this is actually a good thing since the JS API fordag.put()
does encoding for you which means adding this support toblock.put()
allows you to write already encoded dag nodes (which happens to be something I need anyway).And now 3 tests are failing because those tests don't actually write a valid
dag-pb
node, they're just random junk buffers, and/dag/put
actually validates them :)I'll try to get around to fixing the tests and maybe writing a few extras as there's a few new features in here too (when you pass a Block instance it will use the attached cid, so you don't need to pass it in separately). But I won't get to that until next week and I wanted to get some eyeballs on this first.