From 25cf1220e64a418420ae030091882337046fb3cf Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Mon, 27 Jul 2015 18:38:45 +0200 Subject: [PATCH] Reuse vector hashing code for uint256 (cherry picked from commit a3d65fedaa18686f0cc007d0a13dba6545250300) --- src/bloom.cpp | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/src/bloom.cpp b/src/bloom.cpp index e15bc32f9..3f50b1da9 100644 --- a/src/bloom.cpp +++ b/src/bloom.cpp @@ -236,16 +236,8 @@ void CRollingBloomFilter::insert(const std::vector& 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 data(hash.begin(), hash.end()); + insert(data); } bool CRollingBloomFilter::contains(const std::vector& vKey) const @@ -258,10 +250,8 @@ bool CRollingBloomFilter::contains(const std::vector& vKey) const bool CRollingBloomFilter::contains(const uint256& hash) const { - if (nInsertions < nBloomSize / 2) { - return b2.contains(hash); - } - return b1.contains(hash); + vector data(hash.begin(), hash.end()); + return contains(data); } void CRollingBloomFilter::clear()