Skip to content

Commit 2acface

Browse files
committed
Merge #9750: Bloomfilter: parameter variables made constant
64aa36e param variables made const (ロハン ダル) Tree-SHA512: 7c19f9e7dd574c8ce8a9468555f27196735b583efe349c1309c90e1e5d2949daf6891574b4bea7122d6c6aca0c7ee4a782fe3d24918d889f7bf89227084a51cd
2 parents ae78609 + d60d54d commit 2acface

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/bloom.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#define LN2SQUARED 0.4804530139182014246671025263266649717305529515945455
2020
#define LN2 0.6931471805599453094172321214581765680755001343602552
2121

22-
CBloomFilter::CBloomFilter(unsigned int nElements, double nFPRate, unsigned int nTweakIn, unsigned char nFlagsIn) :
22+
CBloomFilter::CBloomFilter(const unsigned int nElements, const double nFPRate, const unsigned int nTweakIn, unsigned char nFlagsIn) :
2323
/**
2424
* The ideal size for a bloom filter with a given number of elements and false positive rate is:
2525
* - nElements * log(fp rate) / ln(2)^2
@@ -40,7 +40,7 @@ CBloomFilter::CBloomFilter(unsigned int nElements, double nFPRate, unsigned int
4040
}
4141

4242
// Private constructor used by CRollingBloomFilter
43-
CBloomFilter::CBloomFilter(unsigned int nElements, double nFPRate, unsigned int nTweakIn) :
43+
CBloomFilter::CBloomFilter(const unsigned int nElements, const double nFPRate, const unsigned int nTweakIn) :
4444
vData((unsigned int)(-1 / LN2SQUARED * nElements * log(nFPRate)) / 8),
4545
isFull(false),
4646
isEmpty(true),
@@ -120,7 +120,7 @@ void CBloomFilter::clear()
120120
isEmpty = true;
121121
}
122122

123-
void CBloomFilter::reset(unsigned int nNewTweak)
123+
void CBloomFilter::reset(const unsigned int nNewTweak)
124124
{
125125
clear();
126126
nTweak = nNewTweak;
@@ -214,7 +214,7 @@ void CBloomFilter::UpdateEmptyFull()
214214
isEmpty = empty;
215215
}
216216

217-
CRollingBloomFilter::CRollingBloomFilter(unsigned int nElements, double fpRate)
217+
CRollingBloomFilter::CRollingBloomFilter(const unsigned int nElements, const double fpRate)
218218
{
219219
double logFpRate = log(fpRate);
220220
/* The optimal number of hash functions is log(fpRate) / log(0.5), but

src/bloom.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class CBloomFilter
5454
unsigned int Hash(unsigned int nHashNum, const std::vector<unsigned char>& vDataToHash) const;
5555

5656
// Private constructor for CRollingBloomFilter, no restrictions on size
57-
CBloomFilter(unsigned int nElements, double nFPRate, unsigned int nTweak);
57+
CBloomFilter(const unsigned int nElements, const double nFPRate, const unsigned int nTweak);
5858
friend class CRollingBloomFilter;
5959

6060
public:
@@ -67,7 +67,7 @@ class CBloomFilter
6767
* It should generally always be a random value (and is largely only exposed for unit testing)
6868
* nFlags should be one of the BLOOM_UPDATE_* enums (not _MASK)
6969
*/
70-
CBloomFilter(unsigned int nElements, double nFPRate, unsigned int nTweak, unsigned char nFlagsIn);
70+
CBloomFilter(const unsigned int nElements, const double nFPRate, const unsigned int nTweak, unsigned char nFlagsIn);
7171
CBloomFilter() : isFull(true), isEmpty(false), nHashFuncs(0), nTweak(0), nFlags(0) {}
7272

7373
ADD_SERIALIZE_METHODS;
@@ -89,7 +89,7 @@ class CBloomFilter
8989
bool contains(const uint256& hash) const;
9090

9191
void clear();
92-
void reset(unsigned int nNewTweak);
92+
void reset(const unsigned int nNewTweak);
9393

9494
//! True if the size is <= MAX_BLOOM_FILTER_SIZE and the number of hash functions is <= MAX_HASH_FUNCS
9595
//! (catch a filter which was just deserialized which was too big)
@@ -122,7 +122,7 @@ class CRollingBloomFilter
122122
// A random bloom filter calls GetRand() at creation time.
123123
// Don't create global CRollingBloomFilter objects, as they may be
124124
// constructed before the randomizer is properly initialized.
125-
CRollingBloomFilter(unsigned int nElements, double nFPRate);
125+
CRollingBloomFilter(const unsigned int nElements, const double nFPRate);
126126

127127
void insert(const std::vector<unsigned char>& vKey);
128128
void insert(const uint256& hash);

0 commit comments

Comments
 (0)