![]() |
Fabcoin Core
0.16.2
P2P Digital Currency
|
BloomFilter is a probabilistic filter which SPV clients provide so that we can filter the transactions we send them. More...
#include <bloom.h>
Public Member Functions | |
CBloomFilter (const unsigned int nElements, const double nFPRate, const unsigned int nTweak, unsigned char nFlagsIn) | |
Creates a new bloom filter which will provide the given fp rate when filled with the given number of elements Note that if the given parameters will result in a filter outside the bounds of the protocol limits, the filter created will be as close to the given parameters as possible within the protocol limits. More... | |
CBloomFilter () | |
template<typename Stream , typename Operation > | |
void | SerializationOp (Stream &s, Operation ser_action) |
void | insert (const std::vector< unsigned char > &vKey) |
void | insert (const COutPoint &outpoint) |
void | insert (const uint256 &hash) |
bool | contains (const std::vector< unsigned char > &vKey) const |
bool | contains (const COutPoint &outpoint) const |
bool | contains (const uint256 &hash) const |
void | clear () |
void | reset (const unsigned int nNewTweak) |
bool | IsWithinSizeConstraints () const |
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) More... | |
bool | IsRelevantAndUpdate (const CTransaction &tx) |
Also adds any outputs which match the filter to the filter (to match their spending txes) More... | |
void | UpdateEmptyFull () |
Checks for empty and full filters to avoid wasting cpu. More... | |
Public Attributes | |
ADD_SERIALIZE_METHODS | |
Private Member Functions | |
unsigned int | Hash (unsigned int nHashNum, const std::vector< unsigned char > &vDataToHash) const |
CBloomFilter (const unsigned int nElements, const double nFPRate, const unsigned int nTweak) | |
Private Attributes | |
std::vector< unsigned char > | vData |
bool | isFull |
bool | isEmpty |
unsigned int | nHashFuncs |
unsigned int | nTweak |
unsigned char | nFlags |
Friends | |
class | CRollingBloomFilter |
BloomFilter is a probabilistic filter which SPV clients provide so that we can filter the transactions we send them.
This allows for significantly more efficient transaction and block downloads.
Because bloom filters are probabilistic, a SPV node can increase the false- positive rate, making us send it transactions which aren't actually its, allowing clients to trade more bandwidth for more privacy by obfuscating which keys are controlled by them.
|
private |
CBloomFilter::CBloomFilter | ( | const unsigned int | nElements, |
const double | nFPRate, | ||
const unsigned int | nTweakIn, | ||
unsigned char | nFlagsIn | ||
) |
Creates a new bloom filter which will provide the given fp rate when filled with the given number of elements Note that if the given parameters will result in a filter outside the bounds of the protocol limits, the filter created will be as close to the given parameters as possible within the protocol limits.
The ideal size for a bloom filter with a given number of elements and false positive rate is:
This will apply if nFPRate is very low or nElements is unreasonably high. nTweak is a constant which is added to the seed value passed to the hash function 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)
void CBloomFilter::clear | ( | ) |
bool CBloomFilter::contains | ( | const std::vector< unsigned char > & | vKey | ) | const |
bool CBloomFilter::contains | ( | const COutPoint & | outpoint | ) | const |
bool CBloomFilter::contains | ( | const uint256 & | hash | ) | const |
|
inlineprivate |
void CBloomFilter::insert | ( | const std::vector< unsigned char > & | vKey | ) |
void CBloomFilter::insert | ( | const COutPoint & | outpoint | ) |
void CBloomFilter::insert | ( | const uint256 & | hash | ) |
bool CBloomFilter::IsRelevantAndUpdate | ( | const CTransaction & | tx | ) |
bool CBloomFilter::IsWithinSizeConstraints | ( | ) | const |
void CBloomFilter::reset | ( | const unsigned int | nNewTweak | ) |
|
inline |
void CBloomFilter::UpdateEmptyFull | ( | ) |
|
friend |