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
Verify supplied hash in JSON I/O #2159
Conversation
@@ -91,6 +92,21 @@ Json::Value formatErrorWithException( | |||
return formatError(_warning, _type, _component, message, formattedMessage, location); | |||
} | |||
|
|||
/// @_hash contains a Keccak256 hash with the 0x prefix |
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.
Should be @param _hash contains...
and I think the main description should be in the first line. I usually just mention the params in the description to avoid redundancy (redundancy often makes you take longer to grasp what it does)
Returns true iff @a _hash (hex with 0x prefix) is the Keccak256 hash of the binary data in @a _content.
Is the 0x
prefix required?
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.
0x
is required by the spec, could be changed though.
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.
What is @a _hash
? Isn't @_hash
working?
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.
No, not as far as I know. @a
tells the doxygen parser that the following word is a function 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.
Actually, we can make a decision whether the hash should be prefixed with 0x
or not. Usually hashes are not prefixed and the other URLs (swarm) which use them do not prefix them either.
@@ -165,8 +181,24 @@ Json::Value StandardCompiler::compileInternal(Json::Value const& _input) | |||
Json::Value errors = Json::arrayValue; | |||
|
|||
for (auto const& sourceName: sources.getMemberNames()) | |||
{ | |||
string 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 assignment is not required.
if (sources[sourceName]["content"].isString()) | ||
m_compilerStack.addSource(sourceName, sources[sourceName]["content"].asString()); | ||
{ | ||
string const& content = sources[sourceName]["content"].asString(); |
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 cannot store by reference if the function returns by value.
false, | ||
"IOError", | ||
"general", | ||
"Mismatch between content and supplied hash for \"" + url.asString() + "\"" |
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 provide the file name and the url? The url might just be a cryptic swarm hash.
3c3bb0c
to
4a9ba5b
Compare
Fixes #2158.