5 #ifndef BITCOIN_BLOCKFILTER_H 6 #define BITCOIN_BLOCKFILTER_H 24 typedef std::vector<unsigned char>
Element;
42 bool MatchInternal(
const uint64_t* sorted_element_hashes,
size_t size)
const;
47 GCSFilter(uint64_t siphash_k0 = 0, uint64_t siphash_k1 = 0, uint8_t P = 0, uint32_t M = 0);
50 GCSFilter(uint64_t siphash_k0, uint64_t siphash_k1, uint8_t P, uint32_t M,
51 std::vector<unsigned char> encoded_filter);
54 GCSFilter(uint64_t siphash_k0, uint64_t siphash_k1, uint8_t P, uint32_t M,
115 template <
typename Stream>
122 template <
typename Stream>
124 std::vector<unsigned char> encoded_filter;
140 throw std::ios_base::failure(
"unknown filter_type");
145 #endif // BITCOIN_BLOCKFILTER_H constexpr uint32_t BASIC_FILTER_M
BlockFilter(BlockFilterType filter_type, const CBlock &block, const CBlockUndo &block_undo)
constexpr uint8_t BASIC_FILTER_P
const GCSFilter & GetFilter() const
bool MatchAny(const ElementSet &elements) const
Checks if any of the given elements may be in the set.
std::vector< uint64_t > BuildHashedSet(const ElementSet &elements) const
bool Match(const Element &element) const
Checks if the element may be in the set.
void Serialize(Stream &s) const
bool MatchInternal(const uint64_t *sorted_element_hashes, size_t size) const
Helper method used to implement Match and MatchAny.
const std::vector< unsigned char > & GetEncodedFilter() const
GCSFilter(uint64_t siphash_k0=0, uint64_t siphash_k1=0, uint8_t P=0, uint32_t M=0)
Constructs an empty filter.
Complete block filter struct as defined in BIP 157.
uint64_t HashToRange(const Element &element) const
Hash a data element to an integer in the range [0, N * M).
This implements a Golomb-coded set as defined in BIP 158.
uint8_t m_P
Golomb-Rice coding parameter.
uint256 ComputeHeader(const uint256 &prev_header) const
Undo information for a CBlock.
BlockFilterType m_filter_type
std::vector< unsigned char > Element
uint32_t m_N
Number of elements in the filter.
BlockFilterType GetFilterType() const
uint64_t GetUint64(int pos) const
uint64_t m_F
Range of element hashes, F = N * M.
uint32_t m_M
Inverse false positive rate.
std::set< Element > ElementSet
std::vector< unsigned char > m_encoded
const std::vector< unsigned char > & GetEncoded() const
void Unserialize(Stream &s)