mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-12 21:02:38 -03:00
refactor: Remove unused methods CBloomFilter::reset()/clear()
Co-authored-by: MarcoFalke <falke.marco@gmail.com>
This commit is contained in:
parent
544709763e
commit
69ffddc83e
4 changed files with 4 additions and 27 deletions
|
@ -102,19 +102,6 @@ bool CBloomFilter::contains(const uint256& hash) const
|
||||||
return contains(data);
|
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
|
bool CBloomFilter::IsWithinSizeConstraints() const
|
||||||
{
|
{
|
||||||
return vData.size() <= MAX_BLOOM_FILTER_SIZE && nHashFuncs <= MAX_HASH_FUNCS;
|
return vData.size() <= MAX_BLOOM_FILTER_SIZE && nHashFuncs <= MAX_HASH_FUNCS;
|
||||||
|
|
|
@ -84,9 +84,6 @@ public:
|
||||||
bool contains(const COutPoint& outpoint) const;
|
bool contains(const COutPoint& outpoint) const;
|
||||||
bool contains(const uint256& hash) 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
|
//! 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)
|
//! (catch a filter which was just deserialized which was too big)
|
||||||
bool IsWithinSizeConstraints() const;
|
bool IsWithinSizeConstraints() const;
|
||||||
|
|
|
@ -27,6 +27,7 @@ BOOST_AUTO_TEST_CASE(bloom_create_insert_serialize)
|
||||||
{
|
{
|
||||||
CBloomFilter filter(3, 0.01, 0, BLOOM_UPDATE_ALL);
|
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"));
|
filter.insert(ParseHex("99108ad8ed9bb6274d3980bab5a85c048f0950c8"));
|
||||||
BOOST_CHECK_MESSAGE( filter.contains(ParseHex("99108ad8ed9bb6274d3980bab5a85c048f0950c8")), "Bloom filter doesn't contain just-inserted object!");
|
BOOST_CHECK_MESSAGE( filter.contains(ParseHex("99108ad8ed9bb6274d3980bab5a85c048f0950c8")), "Bloom filter doesn't contain just-inserted object!");
|
||||||
// One bit different in first byte
|
// One bit different in first byte
|
||||||
|
@ -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_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!");
|
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)
|
BOOST_AUTO_TEST_CASE(bloom_create_insert_serialize_with_tweak)
|
||||||
|
|
|
@ -25,7 +25,7 @@ void test_one_input(const std::vector<uint8_t>& buffer)
|
||||||
fuzzed_data_provider.ConsumeIntegral<unsigned int>(),
|
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}))};
|
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) {
|
while (fuzzed_data_provider.remaining_bytes() > 0) {
|
||||||
switch (fuzzed_data_provider.ConsumeIntegralInRange(0, 6)) {
|
switch (fuzzed_data_provider.ConsumeIntegralInRange(0, 4)) {
|
||||||
case 0: {
|
case 0: {
|
||||||
const std::vector<unsigned char> b = ConsumeRandomLengthByteVector(fuzzed_data_provider);
|
const std::vector<unsigned char> b = ConsumeRandomLengthByteVector(fuzzed_data_provider);
|
||||||
(void)bloom_filter.contains(b);
|
(void)bloom_filter.contains(b);
|
||||||
|
@ -56,13 +56,7 @@ void test_one_input(const std::vector<uint8_t>& buffer)
|
||||||
assert(present);
|
assert(present);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 3:
|
case 3: {
|
||||||
bloom_filter.clear();
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
bloom_filter.reset(fuzzed_data_provider.ConsumeIntegral<unsigned int>());
|
|
||||||
break;
|
|
||||||
case 5: {
|
|
||||||
const Optional<CMutableTransaction> mut_tx = ConsumeDeserializable<CMutableTransaction>(fuzzed_data_provider);
|
const Optional<CMutableTransaction> mut_tx = ConsumeDeserializable<CMutableTransaction>(fuzzed_data_provider);
|
||||||
if (!mut_tx) {
|
if (!mut_tx) {
|
||||||
break;
|
break;
|
||||||
|
@ -71,7 +65,7 @@ void test_one_input(const std::vector<uint8_t>& buffer)
|
||||||
(void)bloom_filter.IsRelevantAndUpdate(tx);
|
(void)bloom_filter.IsRelevantAndUpdate(tx);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 6:
|
case 4:
|
||||||
bloom_filter.UpdateEmptyFull();
|
bloom_filter.UpdateEmptyFull();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue