aboutsummaryrefslogtreecommitdiff
path: root/src/test/bloom_tests.cpp
diff options
context:
space:
mode:
authorPeter Todd <pete@petertodd.org>2015-07-20 04:43:34 +0900
committerPieter Wuille <pieter.wuille@gmail.com>2015-07-27 18:38:49 +0200
commitd2d7ee0e863b286e1c9f9c54659d494fb0a7712d (patch)
treeb955db39fbb776cb59777a1ac171b4cd842496ec /src/test/bloom_tests.cpp
parenta3d65fedaa18686f0cc007d0a13dba6545250300 (diff)
downloadbitcoin-d2d7ee0e863b286e1c9f9c54659d494fb0a7712d.tar.xz
Make CRollingBloomFilter set nTweak for you
While CBloomFilter is usually used with an explicitly set nTweak, CRollingBloomFilter is only used internally. Requiring every caller to set nTweak is error-prone and redundant; better to have the class handle that for you with a high-quality randomness source. Additionally when clearing the filter it makes sense to change nTweak as well to recover from a bad setting, e.g. due to insufficient randomness at initialization, so the clear() method is replaced by a reset() method that sets a new, random, nTweak value.
Diffstat (limited to 'src/test/bloom_tests.cpp')
-rw-r--r--src/test/bloom_tests.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/test/bloom_tests.cpp b/src/test/bloom_tests.cpp
index 1bda8a7ea1..d927be6b81 100644
--- a/src/test/bloom_tests.cpp
+++ b/src/test/bloom_tests.cpp
@@ -469,7 +469,7 @@ static std::vector<unsigned char> RandomData()
BOOST_AUTO_TEST_CASE(rolling_bloom)
{
// last-100-entry, 1% false positive:
- CRollingBloomFilter rb1(100, 0.01, 0);
+ CRollingBloomFilter rb1(100, 0.01, 1);
// Overfill:
static const int DATASIZE=399;
@@ -500,7 +500,7 @@ BOOST_AUTO_TEST_CASE(rolling_bloom)
BOOST_CHECK(nHits < 175);
BOOST_CHECK(rb1.contains(data[DATASIZE-1]));
- rb1.clear();
+ rb1.reset(1);
BOOST_CHECK(!rb1.contains(data[DATASIZE-1]));
// Now roll through data, make sure last 100 entries
@@ -527,7 +527,7 @@ BOOST_AUTO_TEST_CASE(rolling_bloom)
BOOST_CHECK(nHits < 100);
// last-1000-entry, 0.01% false positive:
- CRollingBloomFilter rb2(1000, 0.001, 0);
+ CRollingBloomFilter rb2(1000, 0.001, 1);
for (int i = 0; i < DATASIZE; i++) {
rb2.insert(data[i]);
}