diff options
author | MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> | 2023-02-01 15:56:23 +0100 |
---|---|---|
committer | MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> | 2023-02-01 15:56:30 +0100 |
commit | 8fc3bcf93d0d6ce2a63def154ddc17ecaa1bef8b (patch) | |
tree | 37555655a335182ba7abc5c01eae121f28976e4b /src/blockfilter.cpp | |
parent | 22ccf4e3603a141e5f9485854ba6294cd6876f1e (diff) | |
parent | 87f11ef47fea31d51bcc3f5df68f78fb28e3d8dd (diff) |
Merge bitcoin/bitcoin#27010: refactor: use `Hash` helpers for double-SHA256 calculations
87f11ef47fea31d51bcc3f5df68f78fb28e3d8dd 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 #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 87f11ef47fea31d51bcc3f5df68f78fb28e3d8dd
stickies-v:
ACK 87f11ef47fea31d51bcc3f5df68f78fb28e3d8dd
MarcoFalke:
review ACK 87f11ef47fea31d51bcc3f5df68f78fb28e3d8dd 😬
Tree-SHA512: 11d7e3d00c89685107784010fbffb33ccafb4d1b6a76c4dceb937b29bb234ef4d54581b16bd0737c8d2994a90cf4fe10a9738c7cc5b6d085c6a819f06176dab9
Diffstat (limited to 'src/blockfilter.cpp')
-rw-r--r-- | src/blockfilter.cpp | 15 |
1 files changed, 2 insertions, 13 deletions
diff --git a/src/blockfilter.cpp b/src/blockfilter.cpp index fc6dde20f9..88c7526b9e 100644 --- a/src/blockfilter.cpp +++ b/src/blockfilter.cpp @@ -247,21 +247,10 @@ bool BlockFilter::BuildParams(GCSFilter::Params& params) const uint256 BlockFilter::GetHash() const { - const std::vector<unsigned char>& data = GetEncodedFilter(); - - uint256 result; - CHash256().Write(data).Finalize(result); - return result; + return Hash(GetEncodedFilter()); } uint256 BlockFilter::ComputeHeader(const uint256& prev_header) const { - const uint256& filter_hash = GetHash(); - - uint256 result; - CHash256() - .Write(filter_hash) - .Write(prev_header) - .Finalize(result); - return result; + return Hash(GetHash(), prev_header); } |