-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Implement 'Raw Node' node type #3307
Conversation
@whyrusleeping, what is the ETA for this. (Ideally I would like my filestore code (#2634) to go in before this.) Other than the usual conflicts my main concern is that this is implemented in a way the filestore can use it. In order for that to happen the filestore needs to know what format the block is in. If it is the old format it needs to decode it, if it is raw it needs to do nothing. |
@kevina you will be able to check the cid, or do a type switch on the object. It should actually make things easier for you |
4b1629d
to
92c74f0
Compare
License: MIT Signed-off-by: Jeromy <why@ipfs.io>
92c74f0
to
ded60a7
Compare
@whyrusleeping if possible please try not to rebase this, I merged this into kevina/filestore. |
@whyrusleeping I notice that neither "ipfs cat" or "ipfs get" work with raw nodes. Can I take it that those parts are just not implemented yet? Also (although it does not need to go into this pull request) I would suggest that the DagService GetLinks() method has a special case for Raw Nodes to avoid having to unnecessary retrieve a Raw Node when it is not required. |
Ohhhh... yeah. I should make sure cat and get work with raw nodes. Thats an issue. |
License: MIT Signed-off-by: Jeromy <why@ipfs.io>
@whyrusleeping I can cat large files, but not small ones, for example:
Note: I don't mind if you rebase 3796e70 (but not ded60a7 as that was was merged in, while 3796e70 was cherry picked). |
@kevina fixed the add/cat of small files |
License: MIT Signed-off-by: Jeromy <why@ipfs.io>
55b20ff
to
8ce9963
Compare
test_expect_success "ipfs add --only-hash succeeds" ' | ||
echo "unknown content for only-hash" | ipfs add --only-hash -q > oh_hash | ||
' | ||
|
||
#TODO: this doesn't work when online hence separated out from test_add_cat_file | ||
#TODO: this doesnt work when online hence separated out from test_add_cat_file |
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? "doesnt"
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 removed it because it messed up my syntax highlighting.
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.
okay.
@whyrusleeping have you tried this when HashOnRead() is true? It looks like the verification code in |
License: MIT Signed-off-by: Jeromy <why@ipfs.io>
@kevina good catch, fixed! Anything else you can see? |
I am working on adding raw node support to the filestore, i let you know if I see anything else missing :) |
I would feel much better about it if we run full tests with it enabled by default. |
@@ -124,9 +137,20 @@ func (n *UnixfsNode) SetData(data []byte) { | |||
n.ufmt.Data = data | |||
} | |||
|
|||
func (n *UnixfsNode) DataSize() uint64 { |
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.
Is there a reason you called this DataSize() and not FileSize()? FileSize() means the size of the file if this node was the root. In #3314 I added a similar helper method but I called it FileSize() and not DataSize().
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.
Yeah, FileSize
probably makes more sense, i'll change it.
@Kubuxu running the tests with it enabled by default will be hard. All the hashes will be different. |
License: MIT Signed-off-by: Jeromy <why@ipfs.io>
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.
Left one comment.
I generally feel not great about the quasi state when some features will work some won't in case of raw nodes.
About tests: we should change our tests to keep the all added blocks/files in one place so later the hashes can be remapped easily.
@@ -417,8 +418,14 @@ func (i *gatewayHandler) putHandler(w http.ResponseWriter, r *http.Request) { | |||
return | |||
} | |||
|
|||
pbnewnode, ok := newnode.(*dag.ProtoNode) | |||
if !ok { | |||
webError(w, "Cannot read non protobuf nodes through gateway", dag.ErrNotProtobuf, http.StatusBadRequest) |
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.
As far as I can see it is put handler?
Does reading rawnodes through gateway work?
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.
Yeah, reading raw nodes through the gateway uses the dagreader, which works fine. This nasty hacky area of code is the writeable gateway, which we don't really use...
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 change "Cannot read" to "Cannot write".
I have added this to the filestore and things seam to work. I would say to go ahead and let this is even if there are still places that might brake with the raw nodes. |
Hey @christynelson467 - thanks for the message. Please try and keep comments relevant to the conversation at hand. Open a new issue if you have any questions about go-ipfs. Thanks. |
This PR implements a 'Raw Node' dag node that is essentially just a block. Among other things, this allows us to make unixfs not have leaf nodes with extra framing and fit nicely inside multiples of 1024 and 4096.
A new flag
--raw-leaves
has been added toipfs add
that enables this functionality.Do note that if you create objects with this flag, you will not be able to transfer them to other peers who are running any version before this (meaning those objects will not be able to be processed by ipfs 0.4.3 nodes).
This depends on the previous PR that turns the merkledag.Node into an interface.