-
Notifications
You must be signed in to change notification settings - Fork 37.8k
refactor: use Hash
helpers for double-SHA256 calculations
#27010
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
refactor: use Hash
helpers for double-SHA256 calculations
#27010
Conversation
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ReviewsSee the guideline for information on the review process.
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
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.
ACK 87f11ef
It does make it far more readable. I looked and couldn't find any other suitable places to use the helpers.
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.
ACK 87f11ef
Avoid duplication, easier to read, can't see behaviour change.
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.
review ACK 87f11ef 😬
Show signature
Signature:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512
review ACK 87f11ef47fea31d51bcc3f5df68f78fb28e3d8dd 😬
-----BEGIN PGP SIGNATURE-----
iQGzBAEBCgAdFiEE+rVPoUahrI9sLGYTzit1aX5ppUgFAlwqrYAACgkQzit1aX5p
pUj9lQv9HytY6oVQ1voN8ClRAJIVVgNODDZQbZV2TzpietMli+PyOukp1S4vyXCx
+vz3mPAwrp0mw64GxwnLyc7UoLw9CVG3b2lzbvUnAvPGYMBAY7wxbWH6HMqeyKPI
XtKQyA8lvp5Fo++4Cn59lWtQejlMsvHHQA3jakmkPwDmDsDbptBETcfgfOqrTILC
wCBr4R6/4ml5UZ4ziIrnxzXmzzjc58wHuCld26HcqLlkIl1P6QBkiouybXfjwlH1
q5IWW6v0zEH01ocw6FCLyWwZyXkiGGh8DWGwUIF7WnKQ4sKifPa1o26eE3IIPY82
+u7IjkJSdgz8tWAYeViAq5mAZGgV0+OrArkMzBhgDLsGbd+/2bhjhGjhF+EEJBto
kZWgo7A73RTDkmRv+xaXCCD+OtmgAmc+eMH0kwQiEVtDVvlhV1Bou7PUA91VK3Va
Nc/2iQmwrPCrDZxsSgdgXJ6sZB12fLOX1ii/r4ti5OLxNWN/L56jh6nb9V3uaWRu
jWfVWwuU
=mACN
-----END PGP SIGNATURE-----
…alculations 87f11ef refactor: use `Hash` helper for double-SHA256 calculations (Sebastian Falbesoner) Pull request description: We have two helper templates `Hash(const T& in1)` and `Hash(const T& in1, const T& in2)` available for calculating the double-SHA256 hash of one object or two concatenated objects, respectively: https://github.com/bitcoin/bitcoin/blob/b5868f4b1f884e8d6612f34ca4005fe3a992053d/src/hash.h#L74-L89 This PR uses them in order to increase readability and simplify the code. As in bitcoin#15294 (which inspired this PR, doing the same for RIPEMD160), the helper is not utilized in validation.cpp and script/interpreter.cpp to avoid touching consensus-relevant code. ACKs for top commit: john-moffett: ACK 87f11ef stickies-v: ACK 87f11ef MarcoFalke: review ACK 87f11ef 😬 Tree-SHA512: 11d7e3d00c89685107784010fbffb33ccafb4d1b6a76c4dceb937b29bb234ef4d54581b16bd0737c8d2994a90cf4fe10a9738c7cc5b6d085c6a819f06176dab9
We have two helper templates
Hash(const T& in1)
andHash(const T& in1, const T& in2)
available for calculating the double-SHA256 hash of one object or two concatenated objects, respectively:bitcoin/src/hash.h
Lines 74 to 89 in b5868f4
This PR uses them in order to increase readability and simplify the code. As in #15294 (which inspired this PR, doing the same for RIPEMD160), the helper is not utilized in validation.cpp and script/interpreter.cpp to avoid touching consensus-relevant code.