Add nFlags to CBloomFilter to make filter updating optional.
This commit is contained in:
15
src/bloom.h
15
src/bloom.h
@@ -16,6 +16,16 @@ class CTransaction;
|
||||
static const unsigned int MAX_BLOOM_FILTER_SIZE = 36000; // bytes
|
||||
static const unsigned int MAX_HASH_FUNCS = 50;
|
||||
|
||||
// First two bits of nFlags control how much IsRelevantAndUpdate actually updates
|
||||
// The remaining bits are reserved
|
||||
enum bloomflags
|
||||
{
|
||||
BLOOM_UPDATE_NONE = 0,
|
||||
BLOOM_UPDATE_ALL = 1,
|
||||
// Only adds outpoints to the filter if the output is a pay-to-pubkey/pay-to-multisig script
|
||||
BLOOM_UPDATE_P2PUBKEY_ONLY = 2,
|
||||
BLOOM_UPDATE_MASK = 3,
|
||||
};
|
||||
|
||||
/**
|
||||
* BloomFilter is a probabilistic filter which SPV clients provide
|
||||
@@ -34,6 +44,7 @@ private:
|
||||
std::vector<unsigned char> vData;
|
||||
unsigned int nHashFuncs;
|
||||
unsigned int nTweak;
|
||||
unsigned char nFlags;
|
||||
|
||||
unsigned int Hash(unsigned int nHashNum, const std::vector<unsigned char>& vDataToHash) const;
|
||||
|
||||
@@ -44,7 +55,8 @@ public:
|
||||
// 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)
|
||||
CBloomFilter(unsigned int nElements, double nFPRate, unsigned int nTweak);
|
||||
// nFlags should be one of the BLOOM_UPDATE_* enums (not _MASK)
|
||||
CBloomFilter(unsigned int nElements, double nFPRate, unsigned int nTweak, unsigned char nFlagsIn);
|
||||
// Using a filter initialized with this results in undefined behavior
|
||||
// Should only be used for deserialization
|
||||
CBloomFilter() {}
|
||||
@@ -54,6 +66,7 @@ public:
|
||||
READWRITE(vData);
|
||||
READWRITE(nHashFuncs);
|
||||
READWRITE(nTweak);
|
||||
READWRITE(nFlags);
|
||||
)
|
||||
|
||||
void insert(const std::vector<unsigned char>& vKey);
|
||||
|
||||
Reference in New Issue
Block a user