aboutsummaryrefslogtreecommitdiff
path: root/src/bloom.cpp
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2015-07-27 18:38:45 +0200
committerPieter Wuille <pieter.wuille@gmail.com>2015-07-27 18:38:45 +0200
commita3d65fedaa18686f0cc007d0a13dba6545250300 (patch)
tree35bcf6a7cd121b5908f28a409c403fedff065fdb /src/bloom.cpp
parentbbe41088c61f2ad328766e851ffe6169aa80935a (diff)
downloadbitcoin-a3d65fedaa18686f0cc007d0a13dba6545250300.tar.xz
Reuse vector hashing code for uint256
Diffstat (limited to 'src/bloom.cpp')
-rw-r--r--src/bloom.cpp18
1 files changed, 4 insertions, 14 deletions
diff --git a/src/bloom.cpp b/src/bloom.cpp
index e15bc32f97..3f50b1da91 100644
--- a/src/bloom.cpp
+++ b/src/bloom.cpp
@@ -236,16 +236,8 @@ void CRollingBloomFilter::insert(const std::vector<unsigned char>& vKey)
void CRollingBloomFilter::insert(const uint256& hash)
{
- if (nInsertions == 0) {
- b1.clear();
- } else if (nInsertions == nBloomSize / 2) {
- b2.clear();
- }
- b1.insert(hash);
- b2.insert(hash);
- if (++nInsertions == nBloomSize) {
- nInsertions = 0;
- }
+ vector<unsigned char> data(hash.begin(), hash.end());
+ insert(data);
}
bool CRollingBloomFilter::contains(const std::vector<unsigned char>& vKey) const
@@ -258,10 +250,8 @@ bool CRollingBloomFilter::contains(const std::vector<unsigned char>& vKey) const
bool CRollingBloomFilter::contains(const uint256& hash) const
{
- if (nInsertions < nBloomSize / 2) {
- return b2.contains(hash);
- }
- return b1.contains(hash);
+ vector<unsigned char> data(hash.begin(), hash.end());
+ return contains(data);
}
void CRollingBloomFilter::clear()