mirror of
https://github.com/dashpay/dash.git
synced 2024-12-27 04:52:59 +01:00
Reuse vector hashing code for uint256
This commit is contained in:
parent
bbe41088c6
commit
a3d65fedaa
@ -236,16 +236,8 @@ void CRollingBloomFilter::insert(const std::vector<unsigned char>& vKey)
|
|||||||
|
|
||||||
void CRollingBloomFilter::insert(const uint256& hash)
|
void CRollingBloomFilter::insert(const uint256& hash)
|
||||||
{
|
{
|
||||||
if (nInsertions == 0) {
|
vector<unsigned char> data(hash.begin(), hash.end());
|
||||||
b1.clear();
|
insert(data);
|
||||||
} else if (nInsertions == nBloomSize / 2) {
|
|
||||||
b2.clear();
|
|
||||||
}
|
|
||||||
b1.insert(hash);
|
|
||||||
b2.insert(hash);
|
|
||||||
if (++nInsertions == nBloomSize) {
|
|
||||||
nInsertions = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CRollingBloomFilter::contains(const std::vector<unsigned char>& vKey) const
|
bool CRollingBloomFilter::contains(const std::vector<unsigned char>& vKey) const
|
||||||
@ -258,10 +250,8 @@ bool CRollingBloomFilter::contains(const std::vector<unsigned char>& vKey) const
|
|||||||
|
|
||||||
bool CRollingBloomFilter::contains(const uint256& hash) const
|
bool CRollingBloomFilter::contains(const uint256& hash) const
|
||||||
{
|
{
|
||||||
if (nInsertions < nBloomSize / 2) {
|
vector<unsigned char> data(hash.begin(), hash.end());
|
||||||
return b2.contains(hash);
|
return contains(data);
|
||||||
}
|
|
||||||
return b1.contains(hash);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CRollingBloomFilter::clear()
|
void CRollingBloomFilter::clear()
|
||||||
|
Loading…
Reference in New Issue
Block a user