mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 20:12:57 +01:00
Merge pull request #4568
9c34731
CBloomFilter::clear() method (Tom Harding)
This commit is contained in:
commit
2870014f3a
@ -94,6 +94,13 @@ bool CBloomFilter::contains(const uint256& hash) const
|
||||
return contains(data);
|
||||
}
|
||||
|
||||
void CBloomFilter::clear()
|
||||
{
|
||||
vData.assign(vData.size(),0);
|
||||
isFull = false;
|
||||
isEmpty = true;
|
||||
}
|
||||
|
||||
bool CBloomFilter::IsWithinSizeConstraints() const
|
||||
{
|
||||
return vData.size() <= MAX_BLOOM_FILTER_SIZE && nHashFuncs <= MAX_HASH_FUNCS;
|
||||
|
@ -78,6 +78,8 @@ public:
|
||||
bool contains(const COutPoint& outpoint) const;
|
||||
bool contains(const uint256& hash) const;
|
||||
|
||||
void clear();
|
||||
|
||||
// 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;
|
||||
|
@ -45,6 +45,10 @@ BOOST_AUTO_TEST_CASE(bloom_create_insert_serialize)
|
||||
expected[i] = (char)vch[i];
|
||||
|
||||
BOOST_CHECK_EQUAL_COLLECTIONS(stream.begin(), stream.end(), expected.begin(), expected.end());
|
||||
|
||||
BOOST_CHECK_MESSAGE( filter.contains(ParseHex("99108ad8ed9bb6274d3980bab5a85c048f0950c8")), "BloomFilter doesn't contain just-inserted object!");
|
||||
filter.clear();
|
||||
BOOST_CHECK_MESSAGE( !filter.contains(ParseHex("99108ad8ed9bb6274d3980bab5a85c048f0950c8")), "BloomFilter should be empty!");
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(bloom_create_insert_serialize_with_tweak)
|
||||
|
Loading…
Reference in New Issue
Block a user