Merge #9750: Bloomfilter: parameter variables made constant
64aa36e param variables made const (ロハン ダル) Tree-SHA512: 7c19f9e7dd574c8ce8a9468555f27196735b583efe349c1309c90e1e5d2949daf6891574b4bea7122d6c6aca0c7ee4a782fe3d24918d889f7bf89227084a51cd
This commit is contained in:
parent
64d4113e01
commit
895c95cd90
@ -23,7 +23,7 @@
|
||||
#define LN2SQUARED 0.4804530139182014246671025263266649717305529515945455
|
||||
#define LN2 0.6931471805599453094172321214581765680755001343602552
|
||||
|
||||
CBloomFilter::CBloomFilter(unsigned int nElements, double nFPRate, unsigned int nTweakIn, unsigned char nFlagsIn) :
|
||||
CBloomFilter::CBloomFilter(const unsigned int nElements, const double nFPRate, const unsigned int nTweakIn, unsigned char nFlagsIn) :
|
||||
/**
|
||||
* The ideal size for a bloom filter with a given number of elements and false positive rate is:
|
||||
* - nElements * log(fp rate) / ln(2)^2
|
||||
@ -44,7 +44,7 @@ CBloomFilter::CBloomFilter(unsigned int nElements, double nFPRate, unsigned int
|
||||
}
|
||||
|
||||
// Private constructor used by CRollingBloomFilter
|
||||
CBloomFilter::CBloomFilter(unsigned int nElements, double nFPRate, unsigned int nTweakIn) :
|
||||
CBloomFilter::CBloomFilter(const unsigned int nElements, const double nFPRate, const unsigned int nTweakIn) :
|
||||
vData((unsigned int)(-1 / LN2SQUARED * nElements * log(nFPRate)) / 8),
|
||||
isFull(false),
|
||||
isEmpty(true),
|
||||
@ -130,7 +130,7 @@ void CBloomFilter::clear()
|
||||
isEmpty = true;
|
||||
}
|
||||
|
||||
void CBloomFilter::reset(unsigned int nNewTweak)
|
||||
void CBloomFilter::reset(const unsigned int nNewTweak)
|
||||
{
|
||||
clear();
|
||||
nTweak = nNewTweak;
|
||||
@ -299,7 +299,7 @@ void CBloomFilter::UpdateEmptyFull()
|
||||
isEmpty = empty;
|
||||
}
|
||||
|
||||
CRollingBloomFilter::CRollingBloomFilter(unsigned int nElements, double fpRate)
|
||||
CRollingBloomFilter::CRollingBloomFilter(const unsigned int nElements, const double fpRate)
|
||||
{
|
||||
double logFpRate = log(fpRate);
|
||||
/* The optimal number of hash functions is log(fpRate) / log(0.5), but
|
||||
|
@ -56,7 +56,7 @@ private:
|
||||
unsigned int Hash(unsigned int nHashNum, const std::vector<unsigned char>& vDataToHash) const;
|
||||
|
||||
// Private constructor for CRollingBloomFilter, no restrictions on size
|
||||
CBloomFilter(unsigned int nElements, double nFPRate, unsigned int nTweak);
|
||||
CBloomFilter(const unsigned int nElements, const double nFPRate, const unsigned int nTweak);
|
||||
friend class CRollingBloomFilter;
|
||||
|
||||
// Check matches for arbitrary script data elements
|
||||
@ -73,7 +73,7 @@ public:
|
||||
* It should generally always be a random value (and is largely only exposed for unit testing)
|
||||
* nFlags should be one of the BLOOM_UPDATE_* enums (not _MASK)
|
||||
*/
|
||||
CBloomFilter(unsigned int nElements, double nFPRate, unsigned int nTweak, unsigned char nFlagsIn);
|
||||
CBloomFilter(const unsigned int nElements, const double nFPRate, const unsigned int nTweak, unsigned char nFlagsIn);
|
||||
CBloomFilter() : isFull(true), isEmpty(false), nHashFuncs(0), nTweak(0), nFlags(0) {}
|
||||
|
||||
ADD_SERIALIZE_METHODS;
|
||||
@ -96,7 +96,7 @@ public:
|
||||
bool contains(const uint160& hash) const;
|
||||
|
||||
void clear();
|
||||
void reset(unsigned int nNewTweak);
|
||||
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
|
||||
//! (catch a filter which was just deserialized which was too big)
|
||||
@ -129,7 +129,7 @@ public:
|
||||
// A random bloom filter calls GetRand() at creation time.
|
||||
// Don't create global CRollingBloomFilter objects, as they may be
|
||||
// constructed before the randomizer is properly initialized.
|
||||
CRollingBloomFilter(unsigned int nElements, double nFPRate);
|
||||
CRollingBloomFilter(const unsigned int nElements, const double nFPRate);
|
||||
|
||||
void insert(const std::vector<unsigned char>& vKey);
|
||||
void insert(const uint256& hash);
|
||||
|
Loading…
Reference in New Issue
Block a user