aboutsummaryrefslogtreecommitdiff
path: root/src/blockfilter.cpp
diff options
context:
space:
mode:
authorJim Posen <jimpo@coinbase.com>2018-01-23 17:32:46 -0800
committerJim Posen <jim.posen@gmail.com>2018-08-25 10:02:37 -0700
commita4afb9cadbaecb0676e6475ab8d32a52faecb47a (patch)
treedf0d824aaa7687fb97c7153ea4826e2267eaab73 /src/blockfilter.cpp
parentcd09c7925b5af4104834971cfe072251e3ac2bda (diff)
downloadbitcoin-a4afb9cadbaecb0676e6475ab8d32a52faecb47a.tar.xz
blockfilter: Additional helper methods to compute hash and header.
Diffstat (limited to 'src/blockfilter.cpp')
-rw-r--r--src/blockfilter.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/blockfilter.cpp b/src/blockfilter.cpp
index 1119b54901..124cbcfd92 100644
--- a/src/blockfilter.cpp
+++ b/src/blockfilter.cpp
@@ -233,3 +233,24 @@ BlockFilter::BlockFilter(BlockFilterType filter_type, const CBlock& block, const
throw std::invalid_argument("unknown filter_type");
}
}
+
+uint256 BlockFilter::GetHash() const
+{
+ const std::vector<unsigned char>& data = GetEncodedFilter();
+
+ uint256 result;
+ CHash256().Write(data.data(), data.size()).Finalize(result.begin());
+ return result;
+}
+
+uint256 BlockFilter::ComputeHeader(const uint256& prev_header) const
+{
+ const uint256& filter_hash = GetHash();
+
+ uint256 result;
+ CHash256()
+ .Write(filter_hash.begin(), filter_hash.size())
+ .Write(prev_header.begin(), prev_header.size())
+ .Finalize(result.begin());
+ return result;
+}