Infer multihash resource update content when datalength header is 0#214
Infer multihash resource update content when datalength header is 0#214gbalint merged 12 commits intoswarm-network-rewritefrom
Conversation
a6fcb8c to
97b5f59
Compare
There was a problem hiding this comment.
do we need to PR the swarm BMT hash to multihash?
There was a problem hiding this comment.
I don't know, do we? Let's discuss separately.
There was a problem hiding this comment.
We should, along with a spec of its exact construction. We currently have a hack in go-meta to register it ourselves.
There was a problem hiding this comment.
Yes, the package is not actually in use now in the repo. Until it is necessary to add it, let's do away with the extra bloat. This check is perfectly valid according to the spec, afaics.
There was a problem hiding this comment.
This context usage is ineffective. Since cancel is being deferred, it will only be called after the call to NewResource returns, therefore nothing will get cancelled.
We should just pass context.Background() directly to NewResource.
There was a problem hiding this comment.
We should, along with a spec of its exact construction. We currently have a hack in go-meta to register it ourselves.
There was a problem hiding this comment.
Isn't this a little bit too much logging? They are fine during development, but probably they could be removed, or at least set to Debug. On the other hand the error cases are only logged with Debug level, although those could be Warns or Errors maybe.
There was a problem hiding this comment.
teardownTest() should be right after the setupTest, call, otherwise it will not run if setupTest gives back an error.
There was a problem hiding this comment.
setupTest will only return Error if it can't make tempdir, in which case the teardownTest will be nil.
69e935f to
2e4da30
Compare
7026bfb to
05e09eb
Compare
This PR enables a convenience method for using multihash content in resource updates.
The corresponding method sets the datalength header to 0 in the chunk data. When retrieved, and a datalength header 0 is encountered, the data is resolved as a multihash.
A data integrity check is added to ensure that the first two values in the data are varints, and that the second varint corresponds to the length of the data (or data + signature).