Dash Core Source Documentation (0.16.0.1)
Find detailed information regarding the Dash Core source code.
bloom.cpp
Go to the documentation of this file.
25 CBloomFilter::CBloomFilter(const unsigned int nElements, const double nFPRate, const unsigned int nTweakIn, unsigned char nFlagsIn) :
31 vData(std::min((unsigned int)(-1 / LN2SQUARED * nElements * log(nFPRate)), MAX_BLOOM_FILTER_SIZE * 8) / 8),
46 CBloomFilter::CBloomFilter(const unsigned int nElements, const double nFPRate, const unsigned int nTweakIn) :
56 inline unsigned int CBloomFilter::Hash(unsigned int nHashNum, const std::vector<unsigned char>& vDataToHash) const
255 // is discovered in order to find spending transactions, which avoids round-tripping and race conditions.
307 /* In this rolling bloom filter, we'll store between 2 and 3 generations of nElements / 2 entries. */
317 uint32_t nFilterBits = (uint32_t)ceil(-1.0 * nHashFuncs * nMaxElements / log(1.0 - exp(logFpRate / nHashFuncs)));
329 static inline uint32_t RollingBloomHash(unsigned int nHashNum, uint32_t nTweak, const std::vector<unsigned char>& vDataToHash) {
334 // A replacement for x % n. This assumes that x and n are 32bit integers, and x is a uniformly random distributed 32bit value
364 /* FastMod works with the upper bits of h, so it is safe to ignore that the lower bits of h are already used for bit. */
366 /* The lowest bit of pos is ignored, and set to zero for the first bit, and to one for the second. */
367 data[pos & ~1] = (data[pos & ~1] & ~(((uint64_t)1) << bit)) | ((uint64_t)(nGeneration & 1)) << bit;
368 data[pos | 1] = (data[pos | 1] & ~(((uint64_t)1) << bit)) | ((uint64_t)(nGeneration >> 1)) << bit;
384 /* If the relevant bit is not set in either data[pos & ~1] or data[pos | 1], the filter does not contain vKey */
bool GetTxPayload(const std::vector< unsigned char > &payload, T &obj)
Definition: specialtx.h:21
Definition: transaction.h:16
Definition: providertx.h:187
Definition: standard.h:60
CRollingBloomFilter(const unsigned int nElements, const double nFPRate)
Definition: bloom.cpp:301
void insert(const std::vector< unsigned char > &vKey)
Definition: bloom.cpp:341
Definition: transaction.h:17
bool IsRelevantAndUpdate(const CTransaction &tx)
Also adds any outputs which match the filter to the filter (to match their spending txes) ...
Definition: bloom.cpp:233
Definition: bloom.h:31
Definition: bloom.h:28
Definition: box.hpp:161
static const unsigned int MAX_BLOOM_FILTER_SIZE
20,000 items with fp rate < 0.1% or 10,000 items and <0.0001%
Definition: bloom.h:19
unsigned int Hash(unsigned int nHashNum, const std::vector< unsigned char > &vDataToHash) const
Definition: bloom.cpp:56
Double ended buffer combining vector and stream-like interfaces.
Definition: streams.h:103
Definition: prevector.h:100
Definition: transaction.h:22
bool contains(const std::vector< unsigned char > &vKey) const
Definition: bloom.cpp:378
unsigned int MurmurHash3(unsigned int nHashSeed, const std::vector< unsigned char > &vDataToHash)
Definition: hash.cpp:15
Definition: bloom.h:32
static uint32_t RollingBloomHash(unsigned int nHashNum, uint32_t nTweak, const std::vector< unsigned char > &vDataToHash)
Definition: bloom.cpp:329
Definition: transaction.h:21
Definition: standard.h:63
An outpoint - a combination of a transaction hash and an index n into its vout.
Definition: transaction.h:26
bool Solver(const CScript &scriptPubKey, txnouttype &typeRet, std::vector< std::vector< unsigned char > > &vSolutionsRet)
Parse a scriptPubKey and identify script type for standard scripts.
Definition: standard.cpp:35
bool CheckSpecialTransactionMatchesAndUpdate(const CTransaction &tx)
Definition: bloom.cpp:167
Definition: providertx.h:135
Definition: bloom.h:29
void UpdateEmptyFull()
Checks for empty and full filters to avoid wasting cpu.
Definition: bloom.cpp:288
bool GetOp(iterator &pc, opcodetype &opcodeRet, std::vector< unsigned char > &vchRet)
Definition: script.h:496
Definition: providertx.h:88
The basic transaction that is broadcasted on the network and contained in blocks. ...
Definition: transaction.h:198
Definition: providertx.h:19
Definition: serialize.h:160
bool IsWithinSizeConstraints() const
True if the size is <= MAX_BLOOM_FILTER_SIZE and the number of hash functions is <= MAX_HASH_FUNCS (c...
Definition: bloom.cpp:138
bool contains(const std::vector< unsigned char > &vKey) const
Definition: bloom.cpp:89