Skip to content

Commit 69ffddc

Browse files
theStackMarcoFalke
andcommitted
refactor: Remove unused methods CBloomFilter::reset()/clear()
Co-authored-by: MarcoFalke <[email protected]>
1 parent 5447097 commit 69ffddc

File tree

4 files changed

+4
-27
lines changed

4 files changed

+4
-27
lines changed

src/bloom.cpp

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -102,19 +102,6 @@ bool CBloomFilter::contains(const uint256& hash) const
102102
return contains(data);
103103
}
104104

105-
void CBloomFilter::clear()
106-
{
107-
vData.assign(vData.size(),0);
108-
isFull = false;
109-
isEmpty = true;
110-
}
111-
112-
void CBloomFilter::reset(const unsigned int nNewTweak)
113-
{
114-
clear();
115-
nTweak = nNewTweak;
116-
}
117-
118105
bool CBloomFilter::IsWithinSizeConstraints() const
119106
{
120107
return vData.size() <= MAX_BLOOM_FILTER_SIZE && nHashFuncs <= MAX_HASH_FUNCS;

src/bloom.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,6 @@ class CBloomFilter
8484
bool contains(const COutPoint& outpoint) const;
8585
bool contains(const uint256& hash) const;
8686

87-
void clear();
88-
void reset(const unsigned int nNewTweak);
89-
9087
//! True if the size is <= MAX_BLOOM_FILTER_SIZE and the number of hash functions is <= MAX_HASH_FUNCS
9188
//! (catch a filter which was just deserialized which was too big)
9289
bool IsWithinSizeConstraints() const;

src/test/bloom_tests.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ BOOST_AUTO_TEST_CASE(bloom_create_insert_serialize)
2727
{
2828
CBloomFilter filter(3, 0.01, 0, BLOOM_UPDATE_ALL);
2929

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

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

5756
BOOST_AUTO_TEST_CASE(bloom_create_insert_serialize_with_tweak)

src/test/fuzz/bloom_filter.cpp

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ void test_one_input(const std::vector<uint8_t>& buffer)
2525
fuzzed_data_provider.ConsumeIntegral<unsigned int>(),
2626
static_cast<unsigned char>(fuzzed_data_provider.PickValueInArray({BLOOM_UPDATE_NONE, BLOOM_UPDATE_ALL, BLOOM_UPDATE_P2PUBKEY_ONLY, BLOOM_UPDATE_MASK}))};
2727
while (fuzzed_data_provider.remaining_bytes() > 0) {
28-
switch (fuzzed_data_provider.ConsumeIntegralInRange(0, 6)) {
28+
switch (fuzzed_data_provider.ConsumeIntegralInRange(0, 4)) {
2929
case 0: {
3030
const std::vector<unsigned char> b = ConsumeRandomLengthByteVector(fuzzed_data_provider);
3131
(void)bloom_filter.contains(b);
@@ -56,13 +56,7 @@ void test_one_input(const std::vector<uint8_t>& buffer)
5656
assert(present);
5757
break;
5858
}
59-
case 3:
60-
bloom_filter.clear();
61-
break;
62-
case 4:
63-
bloom_filter.reset(fuzzed_data_provider.ConsumeIntegral<unsigned int>());
64-
break;
65-
case 5: {
59+
case 3: {
6660
const Optional<CMutableTransaction> mut_tx = ConsumeDeserializable<CMutableTransaction>(fuzzed_data_provider);
6761
if (!mut_tx) {
6862
break;
@@ -71,7 +65,7 @@ void test_one_input(const std::vector<uint8_t>& buffer)
7165
(void)bloom_filter.IsRelevantAndUpdate(tx);
7266
break;
7367
}
74-
case 6:
68+
case 4:
7569
bloom_filter.UpdateEmptyFull();
7670
break;
7771
}

0 commit comments

Comments
 (0)