-
Notifications
You must be signed in to change notification settings - Fork 14
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
Add hash validation and support for HTTP(S) and IPFS to command hash anchor-data
#895
Conversation
44caf5e
to
cf9cf24
Compare
eeb9869
to
02d8367
Compare
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.
Nice! Quite elegant solution.
case mExpectedHash of | ||
Just expectedHash | ||
| hash /= expectedHash -> | ||
left $ HashMismatchedHashError expectedHash hash | ||
| otherwise -> liftIO $ putStrLn "Hashes match!" | ||
Nothing -> writeHash hash |
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 code bit is surprising a little: specifying the hash in the CLI argument, makes the command ignore --out-file
argument. I agree that's redundant here, but for the sake of consistency, I would still add writing output file even when the hash is specified as a command line argument.
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 have now changed it for outputting only in case of --out-file
and not in case of stdout
(dda90ab)
I the case of stdout
I am guessing it would be confusing to mix both results
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.
You can print the information message to stderr and the hash to stdout.
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.
Still will be mixed usually, and it is not an error. Not sure. Another option is to print the message to a file instead of the hash when --out-file
is used. Or to make them mutually exclusive
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.
Well stderr isn't reserved only for errors, but is usually used for any kind of diagnostics. I guess ignoring --out-file
would work too if we print a warning here.
@CarlosLopezDeLara thoughts on the UX 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.
I have tried making them mutually exclusive in: cabb16a
I think that works quite well, maybe the problem was trying to do two conflicting things at the same time
11ea69c
to
dda90ab
Compare
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 👍 . Couple of comments and have somebody from devx look at your nix changes.
dda90ab
to
e7e8a8a
Compare
47d4f27
to
4f7cdac
Compare
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
0d48517
to
d0df4c0
Compare
Changelog
Context
This PR is a first step towards solving: #882
But it doesn't completely address it because the check should be in the commands mentioned and not in a separate command. That will be addressed in a separate PR.
How to trust this PR
The tests should provide a lot of assurance. I think the most unverified bit is the URL structure for IPFS_GATEWAYS, but I have tried it against existing gateways and seems to work. Other than that, code style, and maybe code organisation? We may need to move the verification code somewhere else in order to be able to use it in the next PR.
The PR adds quite a few packages, but it was mainly for testing. For querying it uses
http-client
(andhttp-client-tls
for HTTPS support).Checklist