Skip to content

Commit

Permalink
refactor: Remove unused methods CBloomFilter::reset()/clear()
Browse files Browse the repository at this point in the history
Co-authored-by: MarcoFalke <[email protected]>
  • Loading branch information
theStack and MarcoFalke committed Apr 16, 2020
1 parent 5447097 commit 69ffddc
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 27 deletions.
13 changes: 0 additions & 13 deletions src/bloom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,19 +102,6 @@ bool CBloomFilter::contains(const uint256& hash) const
return contains(data);
}

void CBloomFilter::clear()
{
vData.assign(vData.size(),0);
isFull = false;
isEmpty = true;
}

void CBloomFilter::reset(const unsigned int nNewTweak)
{
clear();
nTweak = nNewTweak;
}

bool CBloomFilter::IsWithinSizeConstraints() const
{
return vData.size() <= MAX_BLOOM_FILTER_SIZE && nHashFuncs <= MAX_HASH_FUNCS;
Expand Down
3 changes: 0 additions & 3 deletions src/bloom.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,6 @@ class CBloomFilter
bool contains(const COutPoint& outpoint) const;
bool contains(const uint256& hash) const;

void clear();
void reset(const unsigned int nNewTweak);

//! True if the size is <= MAX_BLOOM_FILTER_SIZE and the number of hash functions is <= MAX_HASH_FUNCS
//! (catch a filter which was just deserialized which was too big)
bool IsWithinSizeConstraints() const;
Expand Down
3 changes: 1 addition & 2 deletions src/test/bloom_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ BOOST_AUTO_TEST_CASE(bloom_create_insert_serialize)
{
CBloomFilter filter(3, 0.01, 0, BLOOM_UPDATE_ALL);

BOOST_CHECK_MESSAGE( !filter.contains(ParseHex("99108ad8ed9bb6274d3980bab5a85c048f0950c8")), "Bloom filter should be empty!");
filter.insert(ParseHex("99108ad8ed9bb6274d3980bab5a85c048f0950c8"));
BOOST_CHECK_MESSAGE( filter.contains(ParseHex("99108ad8ed9bb6274d3980bab5a85c048f0950c8")), "Bloom filter doesn't contain just-inserted object!");
// One bit different in first byte
Expand All @@ -50,8 +51,6 @@ BOOST_AUTO_TEST_CASE(bloom_create_insert_serialize)
BOOST_CHECK_EQUAL_COLLECTIONS(stream.begin(), stream.end(), expected.begin(), expected.end());

BOOST_CHECK_MESSAGE( filter.contains(ParseHex("99108ad8ed9bb6274d3980bab5a85c048f0950c8")), "Bloom filter doesn't contain just-inserted object!");
filter.clear();
BOOST_CHECK_MESSAGE( !filter.contains(ParseHex("99108ad8ed9bb6274d3980bab5a85c048f0950c8")), "Bloom filter should be empty!");
}

BOOST_AUTO_TEST_CASE(bloom_create_insert_serialize_with_tweak)
Expand Down
12 changes: 3 additions & 9 deletions src/test/fuzz/bloom_filter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ void test_one_input(const std::vector<uint8_t>& buffer)
fuzzed_data_provider.ConsumeIntegral<unsigned int>(),
static_cast<unsigned char>(fuzzed_data_provider.PickValueInArray({BLOOM_UPDATE_NONE, BLOOM_UPDATE_ALL, BLOOM_UPDATE_P2PUBKEY_ONLY, BLOOM_UPDATE_MASK}))};
while (fuzzed_data_provider.remaining_bytes() > 0) {
switch (fuzzed_data_provider.ConsumeIntegralInRange(0, 6)) {
switch (fuzzed_data_provider.ConsumeIntegralInRange(0, 4)) {
case 0: {
const std::vector<unsigned char> b = ConsumeRandomLengthByteVector(fuzzed_data_provider);
(void)bloom_filter.contains(b);
Expand Down Expand Up @@ -56,13 +56,7 @@ void test_one_input(const std::vector<uint8_t>& buffer)
assert(present);
break;
}
case 3:
bloom_filter.clear();
break;
case 4:
bloom_filter.reset(fuzzed_data_provider.ConsumeIntegral<unsigned int>());
break;
case 5: {
case 3: {
const Optional<CMutableTransaction> mut_tx = ConsumeDeserializable<CMutableTransaction>(fuzzed_data_provider);
if (!mut_tx) {
break;
Expand All @@ -71,7 +65,7 @@ void test_one_input(const std::vector<uint8_t>& buffer)
(void)bloom_filter.IsRelevantAndUpdate(tx);
break;
}
case 6:
case 4:
bloom_filter.UpdateEmptyFull();
break;
}
Expand Down

0 comments on commit 69ffddc

Please sign in to comment.