param variables made const

pull/9750/head
ロハン ダル 8 years ago
parent d978c41e1e
commit 64aa36e203

@ -19,7 +19,7 @@
#define LN2SQUARED 0.4804530139182014246671025263266649717305529515945455 #define LN2SQUARED 0.4804530139182014246671025263266649717305529515945455
#define LN2 0.6931471805599453094172321214581765680755001343602552 #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: * 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 * - nElements * log(fp rate) / ln(2)^2
@ -40,7 +40,7 @@ CBloomFilter::CBloomFilter(unsigned int nElements, double nFPRate, unsigned int
} }
// Private constructor used by CRollingBloomFilter // 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), vData((unsigned int)(-1 / LN2SQUARED * nElements * log(nFPRate)) / 8),
isFull(false), isFull(false),
isEmpty(true), isEmpty(true),
@ -120,7 +120,7 @@ void CBloomFilter::clear()
isEmpty = true; isEmpty = true;
} }
void CBloomFilter::reset(unsigned int nNewTweak) void CBloomFilter::reset(const unsigned int nNewTweak)
{ {
clear(); clear();
nTweak = nNewTweak; nTweak = nNewTweak;
@ -214,7 +214,7 @@ void CBloomFilter::UpdateEmptyFull()
isEmpty = empty; isEmpty = empty;
} }
CRollingBloomFilter::CRollingBloomFilter(unsigned int nElements, double fpRate) CRollingBloomFilter::CRollingBloomFilter(const unsigned int nElements, const double fpRate)
{ {
double logFpRate = log(fpRate); double logFpRate = log(fpRate);
/* The optimal number of hash functions is log(fpRate) / log(0.5), but /* The optimal number of hash functions is log(fpRate) / log(0.5), but

@ -54,7 +54,7 @@ private:
unsigned int Hash(unsigned int nHashNum, const std::vector<unsigned char>& vDataToHash) const; unsigned int Hash(unsigned int nHashNum, const std::vector<unsigned char>& vDataToHash) const;
// Private constructor for CRollingBloomFilter, no restrictions on size // 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; friend class CRollingBloomFilter;
public: public:
@ -67,7 +67,7 @@ public:
* It should generally always be a random value (and is largely only exposed for unit testing) * 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) * 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) {} CBloomFilter() : isFull(true), isEmpty(false), nHashFuncs(0), nTweak(0), nFlags(0) {}
ADD_SERIALIZE_METHODS; ADD_SERIALIZE_METHODS;
@ -89,7 +89,7 @@ public:
bool contains(const uint256& hash) const; bool contains(const uint256& hash) const;
void clear(); 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 //! 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) //! (catch a filter which was just deserialized which was too big)
@ -122,7 +122,7 @@ public:
// A random bloom filter calls GetRand() at creation time. // A random bloom filter calls GetRand() at creation time.
// Don't create global CRollingBloomFilter objects, as they may be // Don't create global CRollingBloomFilter objects, as they may be
// constructed before the randomizer is properly initialized. // 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 std::vector<unsigned char>& vKey);
void insert(const uint256& hash); void insert(const uint256& hash);

Loading…
Cancel
Save