File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed
Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -234,6 +234,20 @@ void CRollingBloomFilter::insert(const std::vector<unsigned char>& vKey)
234234 }
235235}
236236
237+ void CRollingBloomFilter::insert (const uint256& hash)
238+ {
239+ if (nInsertions == 0 ) {
240+ b1.clear ();
241+ } else if (nInsertions == nBloomSize / 2 ) {
242+ b2.clear ();
243+ }
244+ b1.insert (hash);
245+ b2.insert (hash);
246+ if (++nInsertions == nBloomSize) {
247+ nInsertions = 0 ;
248+ }
249+ }
250+
237251bool CRollingBloomFilter::contains (const std::vector<unsigned char >& vKey) const
238252{
239253 if (nInsertions < nBloomSize / 2 ) {
@@ -242,6 +256,14 @@ bool CRollingBloomFilter::contains(const std::vector<unsigned char>& vKey) const
242256 return b1.contains (vKey);
243257}
244258
259+ bool CRollingBloomFilter::contains (const uint256& hash) const
260+ {
261+ if (nInsertions < nBloomSize / 2 ) {
262+ return b2.contains (hash);
263+ }
264+ return b1.contains (hash);
265+ }
266+
245267void CRollingBloomFilter::clear ()
246268{
247269 b1.clear ();
Original file line number Diff line number Diff line change @@ -114,7 +114,9 @@ class CRollingBloomFilter
114114 CRollingBloomFilter (unsigned int nElements, double nFPRate, unsigned int nTweak);
115115
116116 void insert (const std::vector<unsigned char >& vKey);
117+ void insert (const uint256& hash);
117118 bool contains (const std::vector<unsigned char >& vKey) const ;
119+ bool contains (const uint256& hash) const ;
118120
119121 void clear ();
120122
You can’t perform that action at this time.
0 commit comments